string split vs regex

Benchmark created by ju1ius on


Preparation HTML

<script>
var SPLIT_RX = /[#b]*[1-7]/g,
    TESTS = ['1,2,3,4,5,6,7','1,b2,b3,4,5,b6,b7','1,2,3,#4,#5,6,7','1,b2,#2,3,#4,5,6,b7'];
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
String.prototype.split
TESTS.forEach(function(test){
  var result = test.split(',');
});
ready
String.prototype.match
TESTS.forEach(function(test){
  var result = test.match(SPLIT_RX);
});
ready

Revisions

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

  • Revision 1: published by ju1ius on