The benchmark code: https://play.golang.org/p/qp6wQgqcHKW

The result:

Benchmark_CompareWithSwitch0Bytes-4        328873778             3.619 
ns/op           0 B/op           0 allocs/op
Benchmark_CompareWithSwitch32Bytes-4       175067815             6.251 
ns/op           0 B/op           0 allocs/op
Benchmark_CompareWithSwitch33Bytes-4       25879508            42.86 
ns/op          48 B/op           1 allocs/op

It looks there is still a duplication cost if the slice length <= 32. But 
the benchmark result doesn't reflect this. Does the duplication happen on 
stack?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d0a686f7-b49a-4877-9591-c83fde4545f1n%40googlegroups.com.

Reply via email to