mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 21:58:48 +02:00
perf_hooks: reduce overhead of createHistogram
PR-URL: https://github.com/nodejs/node/pull/50074 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
This commit is contained in:
parent
8e814e3b82
commit
adaef03216
3 changed files with 82 additions and 20 deletions
22
benchmark/perf_hooks/histogram-create.js
Normal file
22
benchmark/perf_hooks/histogram-create.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const common = require('../common.js');
|
||||
|
||||
const { createHistogram } = require('perf_hooks');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e5],
|
||||
});
|
||||
|
||||
let _histogram;
|
||||
|
||||
function main({ n }) {
|
||||
bench.start();
|
||||
for (let i = 0; i < n; i++)
|
||||
_histogram = createHistogram();
|
||||
bench.end(n);
|
||||
|
||||
// Avoid V8 deadcode (elimination)
|
||||
assert.ok(_histogram);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue