node/benchmark/assert/assertion-error.js
Ruben Bridgewater 77607d5306 benchmark: adjust assert runtimes
Each file should have a reasonable runtime while having a good
accuracy. This adjust those up and down to have minimal runtimes
with a good accuracy.

PR-URL: https://github.com/nodejs/node/pull/57370
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
2025-03-12 18:26:15 +00:00

38 lines
648 B
JavaScript

'use strict';
const common = require('../common.js');
const assert = require('assert');
const bench = common.createBenchmark(main, {
n: [200],
size: [2, 75],
});
const baseObject = {
a: 1,
b: {
c: 2,
d: [3, 4, 5],
e: 'fghi',
j: {
k: 6,
},
},
};
function createObjects(size) {
return Array.from({ length: size }, () => baseObject);
}
function main({ n, size }) {
bench.start();
for (let i = 0; i < n; ++i) {
new assert.AssertionError({
actual: {},
expected: createObjects(size),
operator: 'partialDeepStrictEqual',
stackStartFunction: () => {},
});
}
bench.end(n);
}