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

Function main

benchmark/es/spread-bench.js:25–57  ·  view source on GitHub ↗
({ n, context, count, rest, method })

Source from the content-addressed store, hash-verified

23}
24
25function main({ n, context, count, rest, method }) {
26 const ctx = context === 'context' ? {} : null;
27 let fn = makeTest(count, rest);
28 const args = new Array(count);
29
30 for (let i = 0; i < count; i++)
31 args[i] = i;
32
33 switch (method) {
34 case 'apply':
35 bench.start();
36 for (let i = 0; i < n; i++)
37 fn.apply(ctx, args);
38 bench.end(n);
39 break;
40 case 'spread':
41 if (ctx !== null)
42 fn = fn.bind(ctx);
43 bench.start();
44 for (let i = 0; i < n; i++)
45 fn(...args);
46 bench.end(n);
47 break;
48 case 'call-spread':
49 bench.start();
50 for (let i = 0; i < n; i++)
51 fn.call(ctx, ...args);
52 bench.end(n);
53 break;
54 default:
55 throw new Error(`Unexpected method "${method}"`);
56 }
57}

Callers

nothing calls this directly

Calls 7

makeTestFunction · 0.70
fnFunction · 0.50
startMethod · 0.45
applyMethod · 0.45
endMethod · 0.45
bindMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…