diff options
Diffstat (limited to '')
-rw-r--r-- | bench/buffer-read.js (renamed from bench/snippets/buffer-read.js) | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/bench/snippets/buffer-read.js b/bench/buffer-read.js index 314f1d69e..5da645153 100644 --- a/bench/snippets/buffer-read.js +++ b/bench/buffer-read.js @@ -4,24 +4,28 @@ var buf = new Buffer(1024); var view = new DataView(buf.buffer); var INTERVAL = 9999999; var time = (name, fn) => { - for (let i = 0; i < INTERVAL; i++) fn(); + console.log(name, fn()); + // for (let i = 0; i < INTERVAL; i++) fn(); - console.time(name.padEnd("DataView.readBigUInt64 (LE)".length)); - for (let i = 0; i < INTERVAL; i++) fn(); - console.timeEnd(name.padEnd("DataView.readBigUInt64 (LE)".length)); -}; + // console.time(name.padEnd("DataView.readBigUInt64 (LE)".length)); + // for (let i = 0; i < INTERVAL; i++) fn(); + // console.timeEnd(name.padEnd("DataView.readBigUInt64 (LE)".length)); + // }; -console.log( - `Run ${new Intl.NumberFormat().format(INTERVAL)} times with a warmup:`, - "\n" -); + // console.log( + // `Run ${new Intl.NumberFormat().format(INTERVAL)} times with a warmup:`, + // "\n" +}; var array = new Uint8Array(1024); +new Uint8Array(buf.buffer).fill(255); time("Buffer[] ", () => buf[0]); time("Uint8Array[]", () => array[0]); console.log(""); time("Buffer.getBigInt64BE ", () => buf.readBigInt64BE(0)); -time("DataView.getBigInt64 (BE)", () => view.getBigInt64(0, false)); +time("DataView.getBigInt64 (BE)", () => + view.getBigInt64(0, false).toString(10) +); console.log(""); time("Buffer.readBigInt64LE ", () => buf.readBigInt64LE(0)); |