escape-concat

JavaScript performance comparison

Test case created by Fedor Indutny

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function t1(v) {
      return "<html>" + escape(v) + "</html>";
    }
   
    function t2(v) {
      return "<html>" + v + "</html>";
    }
   
    var strs = [],
        offset = 0;
   
    for (var i = 0; i < 1e6; i++) {
      strs.push("big-string #" + i);
    }
};
</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
Escape-concat
var a = t1("str " + offset++);
pending…
Concat
var a = t2("str " + offset++);
pending…
Escape (html)
var a = t1("str <>&;" + offset++);
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