JSON.parse vs String.split (v3)

Revision 3 of this benchmark created on


Preparation HTML

<script>
  var str = "one,two,three,four,dskjaflkjadsfkljasdfjalsfdjsaldjfalksjdflkasjdfklajsdfkjasfdjalksfdjklasjdflkajsdfklasdf;one,two,three,four,dskjaflkjadsfkljasdfjalsfdjsaldjfalksjdflkasjdfklajsdfkjasfdjalksfdjklasjdflkajsdfklasdf;one,two,three,four,dskjaflkjadsfkljasdfjalsfdjsaldjfalksjdflkasjdfklajsdfkjasfdjalksfdjklasjdflkajsdfklasdf;one,two,three,four,dskjaflkjadsfkljasdfjalsfdjsaldjfalksjdflkasjdfklajsdfkjasfdjalksfdjklasjdflkajsdfklasdf;one,two,three,four,dskjaflkjadsfkljasdfjalsfdjsaldjfalksjdflkasjdfklajsdfkjasfdjalksfdjklasjdflkajsdfklasdf;one,two,three,four,dskjaflkjadsfkljasdfjalsfdjsaldjfalksjdflkasjdfklajsdfkjasfdjalksfdjklasjdflkajsdfklasdf;one,two,three,four,dskjaflkjadsfkljasdfjalsfdjsaldjfalksjdflkasjdfklajsdfkjasfdjalksfdjklasjdflkajsdfklasdf;one,two,three,four,dskjaflkjadsfkljasdfjalsfdjsaldjfalksjdflkasjdfklajsdfkjasfdjalksfdjklasjdflkajsdfklasdf";
  var arr = str.split(";");
  for (var i in arr) {
    arr[i] = arr[i].split(",");
  }
</script>

Test runner

Ready to run.

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

Revisions

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