minified or not

JavaScript performance comparison

Test case created by tomByrer

Preparation code

<script src="https://cdn.jsdelivr.net/json-minify/0.1/minify.json.min.js"></script>
<script>var minified = JSON.minify;</script>
<script src="https://cdn.jsdelivr.net/json-minify/0.1/minify.json.js"></script>
<script>var not = JSON.minify;</script>
<!-- Borrowed from @getify's `test.minify.html` -->
<textarea id="orig_json1" cols="50" rows="12">
  // this is a JSON file with comments { "foo": "bar", // this is cool "bar": [ "baz",
  "bum", "zam" ], /* the rest of this document is just fluff in case you are interested.
  */ "something": 10, "else": 20 } /* NOTE: You can easily strip the whitespace and
  comments from such a file with the JSON.minify() project hosted here on github at
  http://github.com/getify/JSON.minify */
</textarea>
<textarea id="orig_json2" cols="50" rows="12">
  {"/*":"*/","//":"",/*"//"*/"/*/":// "//"}
</textarea>
<textarea id="orig_json3" cols="50" rows="12">
  /* this is a multi line comment */{ "foo" : "bar/*"// something , "b\"az":/* something
  else */"blah" }
</textarea>
<textarea id="orig_json4" cols="50" rows="12">
  {"foo": "ba\"r//", "bar\\": "b\\\"a/*z", "baz\\\\": /* yay */ "fo\\\\\"*/o" }
</textarea>
<script>
Benchmark.prototype.setup = function() {
    var first = document.getElementById("orig_json1"),
        second = document.getElementById("orig_json2"),
        third = document.getElementById("orig_json3"),
        fourth = document.getElementById("orig_json4");
};
</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
minified
minified(first);
minified(second);
minified(third);
minified(fourth);
pending…
not
not(first);
not(second);
not(third);
not(fourth);
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