Hacker News new | ask | show | jobs
by Insanity 2622 days ago
Well the code is the same for all of them (but when using a bool map we assign true instead of empty struct). So we run this code inside a benchmarking function:

      m := map[int]interface{}
      // or m := map[int]struct{}
      for i := 0; i < t.N; i++ {
           m[i] = struct{}{}
      }
edit: fix code.
1 comments

I'm speculating, but sizeof(bool) == 1, sizeof(struct{}) == 0 and sizeof(interface{}) == 8, so might be as simple as that.

https://play.golang.org/p/5acy87JLD3i

Yup that well could be it!