Browse Source

buffer: fix dataview-set benchmark

Improves numbers up to 4x by avoiding repetitive dynamic method lookup.

PR-URL: https://github.com/nodejs/node/pull/6922
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
v7.x
Ingvar Stepanyan 9 years ago
committed by Anna Henningsen
parent
commit
4a56e89d20
No known key found for this signature in database GPG Key ID: D8B9F5AEAE84E4CF
  1. 8
      benchmark/buffers/dataview-set.js

8
benchmark/buffers/dataview-set.js

@ -40,18 +40,20 @@ function main(conf) {
}
function benchInt(dv, fn, len, le) {
var m = mod[fn];
const m = mod[fn];
const method = dv[fn];
bench.start();
for (var i = 0; i < len; i++) {
dv[fn](0, i % m, le);
method.call(dv, 0, i % m, le);
}
bench.end(len / 1e6);
}
function benchFloat(dv, fn, len, le) {
const method = dv[fn];
bench.start();
for (var i = 0; i < len; i++) {
dv[fn](0, i * 0.1, le);
method.call(dv, 0, i * 0.1, le);
}
bench.end(len / 1e6);
}

Loading…
Cancel
Save