Build OR Regex (array vs string)

Benchmark created by TeMm on


Description

Push into array and join with pipe, or append to string and slice last pipe.

Preparation HTML

<script>
  var foo = 'foo',
      bar = 'bar',
      baz = 'baz';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Array
var a = [];
a.push(foo);
a.push(bar);
a.push(baz);

var b = a.join('|');
ready
String
var a = '';
a += foo + '|';
a += bar + '|';
a += baz + '|';

var b = a.slice(0, -1);
ready

Revisions

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