On 12/16/2016 07:01 PM, Ondrej wrote:
> Hey,
> I had int as a key in my map and later realised I only used 100 or so
> values, so swapped it for a uint8, expecting a minor speed increase, but
> saw a major slowdown instead. To recreate this, I tried this simple
> microbenchmark and was surprised by the difference between (u)int8/16
> and int/int32/int64.
> 
> https://play.golang.org/p/RxmtASRiS4
> 
> In my actual code I have the key in a slice, so I expected []uint8 to be
> more cache friendly than []int, but I guess any potential cache
> friendliness was outweighed by this hashing performance difference.
> 

It looks like any type that isn't the size of a word is slower.
Probably due to all sort of masking and maybe shifting it has to do.

-ayan

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to