Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions benchmark/buffers/buffer-compare-instance-method.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';
var common = require('../common.js');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const?


var bench = common.createBenchmark(main, {
size: [16, 512, 1024, 4096, 16386],
millions: [1]
});

function main(conf) {
var iter = (conf.millions >>> 0) * 1e6;
var size = (conf.size >>> 0);
var b0 = new Buffer(size).fill('a');
var b1 = new Buffer(size).fill('a');

b1[size - 1] = 'b'.charCodeAt(0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please insert code to force optimization of b0.compare before starting the benchmark. Take a look at some of the other (e.g. path) benchmarks to see how to do this.

bench.start();
for (var i = 0; i < iter; i++) {
b0.compare(b1);
}
bench.end(iter / 1e6);
}