aboutsummaryrefslogtreecommitdiff
path: root/benchmark/buffers/buffer-write.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2017-12-30 03:59:57 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2018-01-23 01:29:31 +0100
commit8e3d7623a54123821ad731c63c8ea661ca5c84c8 (patch)
tree21e692886ede719addbd43160e8832ca721e27e3 /benchmark/buffers/buffer-write.js
parent896397b5dc404dd240a24fd3ba2bf4f7b82a4921 (diff)
downloadandroid-node-v8-8e3d7623a54123821ad731c63c8ea661ca5c84c8.tar.gz
android-node-v8-8e3d7623a54123821ad731c63c8ea661ca5c84c8.tar.bz2
android-node-v8-8e3d7623a54123821ad731c63c8ea661ca5c84c8.zip
benchmark: (buffers) use destructuring
PR-URL: https://github.com/nodejs/node/pull/18250 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'benchmark/buffers/buffer-write.js')
-rw-r--r--benchmark/buffers/buffer-write.js14
1 files changed, 6 insertions, 8 deletions
diff --git a/benchmark/buffers/buffer-write.js b/benchmark/buffers/buffer-write.js
index b500a13ded..ce2fbe3103 100644
--- a/benchmark/buffers/buffer-write.js
+++ b/benchmark/buffers/buffer-write.js
@@ -45,13 +45,11 @@ const mod = {
writeUInt32LE: UINT32
};
-function main(conf) {
- const noAssert = conf.noAssert === 'true';
- const len = +conf.millions * 1e6;
- const clazz = conf.buf === 'fast' ? Buffer : require('buffer').SlowBuffer;
+function main({ noAssert, millions, buf, type }) {
+ const len = millions * 1e6;
+ const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer;
const buff = new clazz(8);
- const type = conf.type || 'UInt8';
- const fn = `write${type}`;
+ const fn = `write${type || 'UInt8'}`;
if (/Int/.test(fn))
benchInt(buff, fn, len, noAssert);
@@ -63,7 +61,7 @@ function benchInt(buff, fn, len, noAssert) {
const m = mod[fn];
const testFunction = new Function('buff', `
for (var i = 0; i !== ${len}; i++) {
- buff.${fn}(i & ${m}, 0, ${JSON.stringify(noAssert)});
+ buff.${fn}(i & ${m}, 0, ${noAssert});
}
`);
bench.start();
@@ -74,7 +72,7 @@ function benchInt(buff, fn, len, noAssert) {
function benchFloat(buff, fn, len, noAssert) {
const testFunction = new Function('buff', `
for (var i = 0; i !== ${len}; i++) {
- buff.${fn}(i, 0, ${JSON.stringify(noAssert)});
+ buff.${fn}(i, 0, ${noAssert});
}
`);
bench.start();