mirror of
https://github.com/nodejs/node.git
synced 2025-04-29 22:40:57 +00:00

PR-URL: https://github.com/nodejs/node/pull/51296 Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
27 lines
560 B
JavaScript
27 lines
560 B
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
const common = require('../common.js');
|
|
|
|
const { createHistogram } = require('perf_hooks');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
n: [1e5],
|
|
});
|
|
|
|
function main({ n }) {
|
|
const histogram = createHistogram();
|
|
bench.start();
|
|
for (let i = 0; i < n; i++) {
|
|
histogram.record(i + 1);
|
|
/* eslint-disable no-unused-expressions */
|
|
histogram.max;
|
|
histogram.mean;
|
|
/* eslint-enable no-unused-expressions */
|
|
}
|
|
bench.end(n);
|
|
|
|
// Avoid V8 deadcode (elimination)
|
|
assert.ok(histogram);
|
|
}
|