0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-24 03:07:54 +01:00
nodejs/benchmark/assert/match.js
RafaelGSS 248d5e0dac benchmark: add match and doesNotMatch bench
PR-URL: https://github.com/nodejs/node/pull/54734
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2024-09-05 15:02:30 +00:00

22 lines
478 B
JavaScript

'use strict';
const common = require('../common.js');
const assert = require('assert');
const bench = common.createBenchmark(main, {
n: [25, 2e7],
method: ['match', 'doesNotMatch'],
});
function main({ n, method }) {
const fn = assert[method];
const actual = 'Example of string that will match';
const expected = method === 'match' ? /will match/ : /will not match/;
bench.start();
for (let i = 0; i < n; ++i) {
fn(actual, expected);
}
bench.end(n);
}