Skip to content

Commit 4078aa8

Browse files
RafaelGSStargos
authored andcommittedOct 2, 2024
benchmark: add match and doesNotMatch bench
PR-URL: #54734 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
1 parent 66acab9 commit 4078aa8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
 

‎benchmark/assert/match.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
const common = require('../common.js');
4+
const assert = require('assert');
5+
6+
const bench = common.createBenchmark(main, {
7+
n: [25, 2e7],
8+
method: ['match', 'doesNotMatch'],
9+
});
10+
11+
function main({ n, method }) {
12+
const fn = assert[method];
13+
const actual = 'Example of string that will match';
14+
const expected = method === 'match' ? /will match/ : /will not match/;
15+
16+
bench.start();
17+
for (let i = 0; i < n; ++i) {
18+
fn(actual, expected);
19+
}
20+
bench.end(n);
21+
}

0 commit comments

Comments
 (0)
Please sign in to comment.