Skip to content

Instantly share code, notes, and snippets.

@maxvipon
Created September 11, 2015 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxvipon/79977e6eacbd6af6825f to your computer and use it in GitHub Desktop.
Save maxvipon/79977e6eacbd6af6825f to your computer and use it in GitHub Desktop.
bench-hash
const Benchmark = require('benchmark').Benchmark;
const siphash = require('siphash');
const murmur = require('murmur');
const HASH_KEY = siphash['string16_to_key']('A054ED26FF2BC196');
const suite = new Benchmark.Suite('Generate Hash');
var hash;
suite
.add('siphash', function() {
siphash.hash(HASH_KEY, Date.now() + 'soult')
})
.add('murmur:unsigned', function() {
murmur.hash128(Date.now() + 'soult').raw();
})
.add('murmur:seed', function() {
murmur.hash128(Date.now() + 'soult', 0xFFFFFFFF).raw()
})
.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').pluck('name'));
})
.run();
@denchistyakov
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment