We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
subarray
buffer-slice
1 parent fe6aa80 commit 093ecfaCopy full SHA for 093ecfa
benchmark/buffers/buffer-slice.js
@@ -3,18 +3,22 @@ const common = require('../common.js');
3
const SlowBuffer = require('buffer').SlowBuffer;
4
5
const bench = common.createBenchmark(main, {
6
- type: ['fast', 'slow'],
+ type: ['fast', 'slow', 'subarray'],
7
n: [1e6]
8
});
9
10
const buf = Buffer.allocUnsafe(1024);
11
const slowBuf = new SlowBuffer(1024);
12
13
function main({ n, type }) {
14
- const b = type === 'fast' ? buf : slowBuf;
+ const b = type === 'slow' ? slowBuf : buf;
15
+ const fn = type === 'subarray' ?
16
+ () => b.subarray(10, 256) :
17
+ () => b.slice(10, 256);
18
+
19
bench.start();
20
for (let i = 0; i < n; i++) {
- b.slice(10, 256);
21
+ fn();
22
}
23
bench.end(n);
24
0 commit comments