3 ms·
You are comparing apples to oranges. The purpose of google algorithm is that, when changing the number of bins, a minimum number of items get moved. This vers
by def-lkb 12y ago
You are comparing apples to oranges.
The purpose of google algorithm is that, when changing the number of bins, a minimum number of items get moved.
This version of your codes prints the number of items which have been reaffected:
https://gist.github.com/def-lkb/58243299e114244d3b90 https://gist.github.com/def-lkb/58243299e114244d3b90
$ ./a.out 1000 1002 100001
google hash 0.0343956 49967527 8.34091e+09, different bins 207
bob jenkins hash 0.0039651 50033275 8.34095e+09, different bins 99794
google is 0.115279x faster
bob is 8.67458x faster
google moved 0.206998x% objects
bob moved 99.793x% objects
optimal distribution required 200 movements (0.199998%)
bob is performing extremely bad.
edit: updated the gist to include the integer version
Also, the google algorithm does O(log(bins)) iterations in the loop, which explains the speed advantage of bob one. Given the task accomplished, it's really efficient and near optimal.
- robmccoll 12y agoVery cool! Thanks, I clearly missed the point :-)