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

Function main

benchmark/buffers/buffer-compare-instance-method.js:10–59  ·  view source on GitHub ↗
({ n, size, args })

Source from the content-addressed store, hash-verified

8});
9
10function main({ n, size, args }) {
11 const b0 = Buffer.alloc(size, 'a');
12 const b1 = Buffer.alloc(size, 'a');
13 const b0Len = b0.length;
14 const b1Len = b1.length;
15
16 b1[size - 1] = 'b'.charCodeAt(0);
17
18 switch (args) {
19 case 2:
20 b0.compare(b1, 0);
21 bench.start();
22 for (let i = 0; i < n; i++) {
23 b0.compare(b1, 0);
24 }
25 bench.end(n);
26 break;
27 case 3:
28 b0.compare(b1, 0, b1Len);
29 bench.start();
30 for (let i = 0; i < n; i++) {
31 b0.compare(b1, 0, b1Len);
32 }
33 bench.end(n);
34 break;
35 case 4:
36 b0.compare(b1, 0, b1Len, 0);
37 bench.start();
38 for (let i = 0; i < n; i++) {
39 b0.compare(b1, 0, b1Len, 0);
40 }
41 bench.end(n);
42 break;
43 case 5:
44 b0.compare(b1, 0, b1Len, 0, b0Len);
45 bench.start();
46 for (let i = 0; i < n; i++) {
47 b0.compare(b1, 0, b1Len, 0, b0Len);
48 }
49 bench.end(n);
50 break;
51 default:
52 b0.compare(b1);
53 bench.start();
54 for (let i = 0; i < n; i++) {
55 b0.compare(b1);
56 }
57 bench.end(n);
58 }
59}

Callers

nothing calls this directly

Calls 4

allocMethod · 0.80
compareMethod · 0.65
startMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…