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>
This commit is contained in:
RafaelGSS 2024-09-03 11:50:34 -03:00 committed by Node.js GitHub Bot
parent b26238132b
commit 248d5e0dac
1 changed files with 21 additions and 0 deletions

21
benchmark/assert/match.js Normal file
View File

@ -0,0 +1,21 @@
'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);
}