From 7dbb0d0084373de454b88c789a5de067b3240564 Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Sun, 22 May 2016 21:06:42 +0100 Subject: [PATCH] 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 Reviewed-By: Trevor Norris Reviewed-By: James M Snell Reviewed-By: Brian White --- benchmark/buffers/dataview-set.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/benchmark/buffers/dataview-set.js b/benchmark/buffers/dataview-set.js index ab9c1d1d23b736..be1f6c48876750 100644 --- a/benchmark/buffers/dataview-set.js +++ b/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); }