eval-vs-parseJSON

JavaScript performance comparison

Test case created by johnner

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 
<script>
Benchmark.prototype.setup = function() {
    var txt = '[{"prizmaId":16,"plazmaId":302315,"showBlogs":false},{"prizmaId":23,"plazmaId":270212,"showBlogs":false},{"prizmaId":26,"plazmaId":323504,"showBlogs":false},{"prizmaId":16,"plazmaId":372318,"showBlogs":true},{"prizmaId":16,"plazmaId":302307,"showBlogs":true},{"prizmaId":16,"plazmaId":606293,"showBlogs":false},{"prizmaId":16,"plazmaId":606295,"showBlogs":false},{"prizmaId":16,"plazmaId":606298,"showBlogs":false},{"prizmaId":16,"plazmaId":405358,"showBlogs":false},{"prizmaId":16,"plazmaId":606303,"showBlogs":false},{"prizmaId":16,"plazmaId":606270,"showBlogs":false},{"prizmaId":16,"plazmaId":482809,"showBlogs":false},{"prizmaId":16,"plazmaId":606279,"showBlogs":false},{"prizmaId":16,"plazmaId":482806,"showBlogs":false},{"prizmaId":16,"plazmaId":567094,"showBlogs":false},{"prizmaId":16,"plazmaId":398013,"showBlogs":false},{"prizmaId":16,"plazmaId":302328,"showBlogs":false},{"prizmaId":16,"plazmaId":302322,"showBlogs":false},{"prizmaId":16,"plazmaId":302344,"showBlogs":false},{"prizmaId":16,"plazmaId":302369,"showBlogs":false},{"prizmaId":16,"plazmaId":302379,"showBlogs":false},{"prizmaId":16,"plazmaId":606309,"showBlogs":false}]'
};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
eval
var parse = function () {
  var themes = eval(txt);
  return themes;
}

for (var i = 0; i < 30; i++) {
  parse();
}
pending…
jsonparse
var parse = function () {
  var themes = $.parseJSON( txt);
  return themes;
}

for (var i = 0; i < 30; i++) {
  parse();
}
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