Skip to content

Commit 4078aa8

Browse files
RafaelGSStargos
authored andcommitted
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

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎benchmark/assert/match.js‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
constcommon=require('../common.js');
4+
constassert=require('assert');
5+
6+
constbench=common.createBenchmark(main,{
7+
n: [25,2e7],
8+
method: ['match','doesNotMatch'],
9+
});
10+
11+
functionmain({ n, method }){
12+
constfn=assert[method];
13+
constactual='Example of string that will match';
14+
constexpected=method==='match' ? /willmatch/ : /willnotmatch/;
15+
16+
bench.start();
17+
for(leti=0;i<n;++i){
18+
fn(actual,expected);
19+
}
20+
bench.end(n);
21+
}

0 commit comments

Comments
 (0)