Skip to content

Commit

Permalink
benchmark: add match and doesNotMatch bench
Browse files Browse the repository at this point in the history
PR-URL: #54734
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
  • Loading branch information
RafaelGSS authored and aduh95 committed Sep 12, 2024
1 parent 2844180 commit 0601644
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions benchmark/assert/match.js
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 0601644

Please sign in to comment.