JSON.parse vs String.split

Benchmark created by Kris Gray on


Preparation HTML

<script>
  var str = "one,two,three,four,dskjaflkjadsfkljasdfjalsfdjsaldjfalksjdflkasjdfklajsdfkjasfdjalksfdjklasjdflkajsdfklasdf";
  var arr = str.split(",");
  
  var jsonstr = JSON.stringify(arr);
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
JSON
var result = JSON.parse(jsonstr);
ready
Split()
var result = str.split(",");
var arr = [];
for(var c=0,l=result.length;c<l;c++) {
arr[c] = decodeURIComponent(result[c]);
}
ready

Revisions

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