diff options
author | Benjamin Gruenbaum <benjamingr@gmail.com> | 2022-01-19 20:58:11 +0300 |
---|---|---|
committer | Danielle Adams <adamzdanielle@gmail.com> | 2022-04-21 03:34:19 +0300 |
commit | 3d4df9cd7075658a36eab143fb0fb740e4f88ea2 (patch) | |
tree | 2f2b38b2b1f88ac85f6ffabcc26c87ae6e023b68 /benchmark | |
parent | e46c7d6f695427af4f3b7f06213b8c3deb679b68 (diff) |
benchmark: add `subarray` to `buffer-slice`
PR-URL: https://github.com/nodejs/node/pull/41596
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/buffers/buffer-slice.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/benchmark/buffers/buffer-slice.js b/benchmark/buffers/buffer-slice.js index a64cbd2ab2d..dcb18754e84 100644 --- a/benchmark/buffers/buffer-slice.js +++ b/benchmark/buffers/buffer-slice.js @@ -3,7 +3,7 @@ const common = require('../common.js'); const SlowBuffer = require('buffer').SlowBuffer; const bench = common.createBenchmark(main, { - type: ['fast', 'slow'], + type: ['fast', 'slow', 'subarray'], n: [1e6] }); @@ -11,10 +11,14 @@ const buf = Buffer.allocUnsafe(1024); const slowBuf = new SlowBuffer(1024); function main({ n, type }) { - const b = type === 'fast' ? buf : slowBuf; + const b = type === 'slow' ? slowBuf : buf; + const fn = type === 'subarray' ? + () => b.subarray(10, 256) : + () => b.slice(10, 256); + bench.start(); for (let i = 0; i < n; i++) { - b.slice(10, 256); + fn(); } bench.end(n); } |