replace regex vs string

Benchmark created on


Preparation HTML

<script>
  var x="10.000 \n 20.000 \n 30.000",
  arr,sum;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Simult
arr=x.replace(/\./g,'').split('\n');
sum=parseInt(arr[0])+parseInt(arr[1])+parseInt(arr[2]);
ready
separate
arr=x.split('\n');
sum=parseInt(arr[0].replace('.',''))+parseInt(arr[1].replace('.',''))+parseInt(arr[2].replace('.',''));
ready

Revisions

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