Skip to content

Commit

Permalink
update benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
alsotang committed Dec 1, 2015
1 parent 44b4588 commit 39538ec
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 126 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,20 @@ murmurhash('hello 中国', 97); // 1248731102
## Benchmark

```
node version: v4.2.1, date: Sun Nov 15 2015 01:01:49 GMT+0800 (CST)
node version: v4.2.1, date: Tue Dec 01 2015 14:06:01 GMT+0800 (CST)
Starting...
2 tests completed.
4 tests completed.
murmurhash(new Buffer(ascii)) x 21,164,676 ops/sec ±0.85% (98 runs sampled)
murmurhash(new Buffer(utf8)) x 13,926,544 ops/sec ±0.59% (99 runs sampled)
murmurhash(new Buffer('haha, this is key')) x 18,416,878 ops/sec ±0.70% (96 runs sampled)
murmurhash(new Buffer('快使用双节棍,嘿嘿嘿嘿。')) x 12,709,085 ops/sec ±0.80% (93 runs sampled)
murmurhash('haha, this is key') x 804,541 ops/sec ±24.21% (90 runs sampled)
murmurhash('快使用双节棍,嘿嘿嘿嘿。') x 797,345 ops/sec ±0.93% (92 runs sampled)
```

see also: [benchmark](test/benchmark.js)
see also: [benchmark.js](test/benchmark.js)


## License

Expand Down
107 changes: 0 additions & 107 deletions benchmark.md

This file was deleted.

31 changes: 17 additions & 14 deletions test/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,30 @@ var Benchmark = require('benchmark');
var benchmarks = require('beautify-benchmark');
var murmurhash = require('../');

var ascii = new Buffer('haha, this is key');
// var utf8 = new Buffer('hello 中国');
var utf8 = new Buffer([
0, 4, 111, 108, 95, 99, 51, 95, 117, 95, 105, 112, 95, -27, -116, -105, -26,
-98, -127, -25, -69, -110, -25, -122, -108, -24, -98, -115, -28, -72, -109,
-27, -115, -106, -27, -70, -105, 95, 112
]);
var asciiBuffer = new Buffer('haha, this is key');
var utf8Buffer = new Buffer('快使用双节棍,嘿嘿嘿嘿。');
var asciiString = 'haha, this is key';
var utf8String = '快使用双节棍,嘿嘿嘿嘿。';

console.log('murmurhash should be 335538535: %s', murmurhash(ascii));
console.log('murmurhash utf8 should be 3300337389: %s', murmurhash(utf8));
console.log('murmurhash with custom key should be 4040304760: %s', murmurhash(utf8, 12333));
console.log('murmurhash should be 335538535: %s', murmurhash(asciiBuffer));
console.log('murmurhash utf8 should be 705333708: %s', murmurhash(utf8Buffer));
console.log('murmurhash with custom key should be 2639541842: %s', murmurhash(utf8Buffer, 12333));
console.log("murmurhash('hello 中国') should be 1248731102: %s", murmurhash('hello 中国'));

var suite = new Benchmark.Suite();

suite
.add("murmurhash(new Buffer(ascii))", function () {
murmurhash(ascii);
.add("murmurhash(new Buffer('haha, this is key'))", function () {
murmurhash(asciiBuffer);
})
.add("murmurhash(new Buffer(utf8))", function () {
murmurhash(utf8);
.add("murmurhash(new Buffer('快使用双节棍,嘿嘿嘿嘿。'))", function () {
murmurhash(utf8Buffer);
})
.add("murmurhash('haha, this is key')", function () {
murmurhash(asciiString);
})
.add("murmurhash('快使用双节棍,嘿嘿嘿嘿。')", function () {
murmurhash(utf8String);
})
.on('cycle', function(event) {
benchmarks.add(event.target);
Expand Down

0 comments on commit 39538ec

Please sign in to comment.