builtin map faster then Lookup
chennqqi opened this issue · comments
chennqqi commented
goos: linux
goarch: amd64
pkg: github.com/alecthomas/mph
BenchmarkBuiltinMap-40 10000000 144 ns/op
BenchmarkCHD-40 10000000 205 ns/op
Caleb Spare commented
Those benchmarks don't come from this package, they come from github.com/alecthomas/mph.
My package also has benchmarks that compare it against the stdlib map and the last time I ran them, mph was faster in that benchmark, though I haven't run it recently.
Caleb Spare commented
FWIW, the MPH implementation in this package does seem faster than a map[string]uint32
, though the gap has closed somewhat:
$ go test -bench Table -benchtime 10s
goos: linux
goarch: amd64
pkg: github.com/cespare/mph
BenchmarkTable 300000000 48.6 ns/op
BenchmarkTableMap 200000000 67.6 ns/op