RegExp timing (v2)

Revision 2 of this benchmark created on


Description

Check what method of regexp is fastest

Test runner

Ready to run.

Testing in
TestOps/sec
new RegExp
var re = new RegExp('sample', 'g'),
    i;
for (i = 1000; i--;) {
  "sample".match(re);
}
ready
literal
var re = /sample/g,
    i;
for (i = 1000; i--;) {
  "sample".match(re);
}
ready
eval
var re = eval('/sample/g'),
    i;
for (i = 1000; i--;) {
  "sample".match(re);
}
ready
internal literal
var i;
for (i = 1000; i--;) {
  "sample".match(/sample/g);
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by Arthur Corenzan on
  • Revision 2: published on