Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6fefd51

Browse filesBrowse files
benjamingrBethGriggs
authored andcommitted
benchmark: add subarray to buffer-slice
PR-URL: #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>
1 parent 2e7bf00 commit 6fefd51
Copy full SHA for 6fefd51

File tree

Expand file treeCollapse file tree

1 file changed

+7
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-3
lines changed
Open diff view settings
Collapse file

‎benchmark/buffers/buffer-slice.js‎

Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-slice.js
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@ const common = require('../common.js');
33
const SlowBuffer = require('buffer').SlowBuffer;
44

55
const bench = common.createBenchmark(main, {
6-
type: ['fast', 'slow'],
6+
type: ['fast', 'slow', 'subarray'],
77
n: [1e6]
88
});
99

1010
const buf = Buffer.allocUnsafe(1024);
1111
const slowBuf = new SlowBuffer(1024);
1212

1313
function main({ n, type }) {
14-
const b = type === 'fast' ? buf : slowBuf;
14+
const b = type === 'slow' ? slowBuf : buf;
15+
const fn = type === 'subarray' ?
16+
() => b.subarray(10, 256) :
17+
() => b.slice(10, 256);
18+
1519
bench.start();
1620
for (let i = 0; i < n; i++) {
17-
b.slice(10, 256);
21+
fn();
1822
}
1923
bench.end(n);
2024
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.