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

Function main

benchmark/error/hidestackframes-throw.js:17–87  ·  view source on GitHub ↗
({ n, type, double })

Source from the content-addressed store, hash-verified

15});
16
17function main({ n, type, double }) {
18 const {
19 hideStackFrames,
20 codes: {
21 ERR_INVALID_ARG_TYPE,
22 },
23 } = require('internal/errors');
24
25 const value = 'err';
26
27 const testfn = (value) => {
28 if (typeof value !== 'number') {
29 throw new ERR_INVALID_ARG_TYPE('Benchmark', 'number', value);
30 }
31 };
32
33 const hideStackFramesTestfn = hideStackFrames((value) => {
34 if (typeof value !== 'number') {
35 throw new ERR_INVALID_ARG_TYPE.HideStackFrameError('Benchmark', 'number', value);
36 }
37 });
38
39 function doubleTestfn(value) {
40 testfn(value);
41 }
42
43 const doubleHideStackFramesTestfn = hideStackFrames((value) => {
44 hideStackFramesTestfn.withoutStackTrace(value);
45 });
46
47 const fn = type === 'hide-stackframe' ?
48 double === 'true' ?
49 doubleHideStackFramesTestfn :
50 hideStackFramesTestfn :
51 double === 'true' ?
52 doubleTestfn :
53 testfn;
54
55 const length = 1024;
56 const array = [];
57 let errCase = false;
58
59 // Warm up.
60 for (let i = 0; i < length; ++i) {
61 try {
62 fn(value);
63 } catch (e) {
64 errCase = true;
65 array.push(e);
66 }
67 }
68
69 bench.start();
70
71 for (let i = 0; i < n; i++) {
72 const index = i % length;
73 try {
74 fn(value);

Callers

nothing calls this directly

Calls 6

hideStackFramesFunction · 0.85
requireFunction · 0.50
fnFunction · 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…