cespare / mph

Minimal perfect hashing in Go
MIT License
72 stars 11 forks source link

Some optimizations #2

Closed alex-schneider closed 1 year ago

cespare commented 2 years ago

Could you include benchstat results if the purpose of the changes is to make it faster? Thanks.

cespare commented 1 year ago

Thanks. But what I meant was that we should look at the effect on Build. We don't actually care how long nextPow2 takes per se; we care how it affects Build, and Build only calls nextPow2 twice (and then does a bunch of expensive stuff). So nextPow2 would only matter if it were extremely slow.

Indeed, when I run the Build benchmark on my machine with and without this change, the difference isn't measurable in the noise:

name      old time/op  new time/op  delta
Build-24  34.5ms ± 4%  34.3ms ± 3%   ~     (p=0.067 n=34+31)