diff options
author | RafaelGSS <rafael.nunu@hotmail.com> | 2022-05-12 22:19:57 +0300 |
---|---|---|
committer | RafaelGSS <rafael.nunu@hotmail.com> | 2022-05-30 15:54:21 +0300 |
commit | 0903515e126c2697042d6546c6aa4b72e1a4b33e (patch) | |
tree | 16f608d485b9d2e8fbdb0ee1fe007517f55fd0fb | |
parent | d72dcb0db451c23df6fa793799e87f63e5e24465 (diff) |
benchmark: add node-error benchmark
PR-URL: https://github.com/nodejs/node/pull/43077
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
-rw-r--r-- | benchmark/error/error.js | 14 | ||||
-rw-r--r-- | benchmark/error/node-error.js | 21 |
2 files changed, 35 insertions, 0 deletions
diff --git a/benchmark/error/error.js b/benchmark/error/error.js new file mode 100644 index 00000000000..c856f3e07f6 --- /dev/null +++ b/benchmark/error/error.js @@ -0,0 +1,14 @@ +'use strict'; + +const common = require('../common.js'); + +const bench = common.createBenchmark(main, { + n: [1e7], +}); + +function main({ n }) { + bench.start(); + for (let i = 0; i < n; ++i) + new Error('test'); + bench.end(n); +} diff --git a/benchmark/error/node-error.js b/benchmark/error/node-error.js new file mode 100644 index 00000000000..f672522b2d0 --- /dev/null +++ b/benchmark/error/node-error.js @@ -0,0 +1,21 @@ +'use strict'; + +const common = require('../common'); + +const bench = common.createBenchmark(main, { + n: [1e7], +}, { + flags: ['--expose-internals'] +}); + +function main({ n }) { + const { + codes: { + ERR_INVALID_STATE, + } + } = require('internal/errors'); + bench.start(); + for (let i = 0; i < n; ++i) + new ERR_INVALID_STATE.TypeError('test'); + bench.end(n); +} |