Split vs json

JavaScript performance comparison

Test case created

Info

testing if splitting a string is faster than json decoding an array.

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var colString = "";
    var preJson = [];
   
    for(i=0;i<=10000;i++) {
    colString += "publisher_" + i + ",";
    preJson.push("publisher_" + i);
    }
    var json = JSON.stringify(preJson);
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
json decode
JSON.parse(json)
pending…
split
colString.split(',')
pending…

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

Compare results of other browsers

0 comments

Add a comment