GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — node/benchmark/error/node-error-stack.js at main · synapse/node Expand file tree/ Copy pathnode-error-stack.jsMore file actions 62 lines (51 loc) · 1.37 KB / Copy pathnode-error-stack.jsFile metadata and controls62 lines (51 loc) · 1.37 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 'use strict'; const common = require('../common'); const assert = require('assert'); const bench = common.createBenchmark(main, { n: [1e6], code: [ 'built-in', 'ERR_HTTP2_STREAM_SELF_DEPENDENCY', 'ERR_INVALID_STATE', ], stackTraceLimit: [0, 10], }, { flags: ['--expose-internals'], }); function getErrorStackFactory(code) { const { ERR_INVALID_STATE, ERR_HTTP2_STREAM_SELF_DEPENDENCY, } = require('internal/errors').codes; switch (code) { case 'built-in': return (n) => new Error().stack; case 'ERR_HTTP2_STREAM_SELF_DEPENDENCY': return (n) => new ERR_HTTP2_STREAM_SELF_DEPENDENCY().stack; case 'ERR_INVALID_STATE': return (n) => new ERR_INVALID_STATE(n + '').stack; default: throw new Error(`${code} not supported`); } } function main({ n, code, stackTraceLimit }) { const getStack = getErrorStackFactory(code); Error.stackTraceLimit = stackTraceLimit; // Warm up. const length = 1024; const array = []; for (let i = 0; i < length; ++i) { array.push(getStack(i)); } bench.start(); for (let i = 0; i < n; ++i) { const index = i % length; array[index] = getStack(index); } bench.end(n); // Verify the entries to prevent dead code elimination from making // the benchmark invalid. for (let i = 0; i < length; ++i) { assert.strictEqual(typeof array[i], 'string'); } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |