MCPcopy Index your code
hub / github.com/nodejs/node / main

Function main

benchmark/buffers/buffer-creation.js:16–44  ·  view source on GitHub ↗
({ len, n, type })

Source from the content-addressed store, hash-verified

14});
15
16function main({ len, n, type }) {
17 let fn, i;
18 switch (type) {
19 case 'fast-alloc':
20 fn = Buffer.alloc;
21 break;
22 case 'fast-alloc-fill':
23 bench.start();
24 for (i = 0; i < n; i++) {
25 Buffer.alloc(len, 0);
26 }
27 bench.end(n);
28 return;
29 case 'fast-allocUnsafe':
30 fn = Buffer.allocUnsafe;
31 break;
32 case 'slow-allocUnsafe':
33 fn = Buffer.allocUnsafeSlow;
34 break;
35 default:
36 assert.fail('Should not get here');
37 }
38
39 bench.start();
40 for (i = 0; i < n; i++) {
41 fn(len);
42 }
43 bench.end(n);
44}

Callers

nothing calls this directly

Calls 5

allocMethod · 0.80
fnFunction · 0.50
startMethod · 0.45
endMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected