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

Function main

benchmark/validators/parse-file-mode.js:24–61  ·  view source on GitHub ↗
({ n, value })

Source from the content-addressed store, hash-verified

22}
23
24function main({ n, value }) {
25 const parse = getParseFactory();
26
27 value = value === "'777'" ? '777' : 0o777;
28
29 // Warm up.
30 const length = 1024;
31 const array = [];
32 let errCase = false;
33
34 for (let i = 0; i < length; ++i) {
35 try {
36 array.push(parse(value));
37 } catch (e) {
38 errCase = true;
39 array.push(e);
40 }
41 }
42
43 bench.start();
44
45 for (let i = 0; i < n; ++i) {
46 const index = i % length;
47 try {
48 array[index] = parse(value);
49 } catch (e) {
50 array[index] = e;
51 }
52 }
53
54 bench.end(n);
55
56 // Verify the entries to prevent dead code elimination from making
57 // the benchmark invalid.
58 for (let i = 0; i < length; ++i) {
59 assert.strictEqual(typeof array[i], errCase ? 'object' : 'number');
60 }
61}

Callers

nothing calls this directly

Calls 5

getParseFactoryFunction · 0.85
parseFunction · 0.50
pushMethod · 0.45
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…