TextPacker

JavaScript performance comparison

Test case created by fastner

Preparation code

<script language="javascript" src="//rawgithub.com/pieroxy/lz-string/master/libs/lz-string-1.3.0.js"></script>
<script language="javascript">
  window.core = {
    Module : function(name, obj) {
      var cur = window;
      name = name.split(".");
      while (name.length > 1) {
        var n = name.shift();
        if (!cur[n]) cur[n] = {};
        cur = cur[n];
      }
      cur[name[0]] = obj;
    }
  };
var glob = window;
core.Module("core.Main", {
  getGlobal : function() { return glob; }
});
var input1 = ""; // 30 characters long
var input2 = ""; // 500 characters long
var input3 = ""; // 10000 characters long
var ch = "abcdefghijklmnopqrstuvwxyz";
for (var i=0; i<30; i++) {
input1 += ch[Math.floor(Math.random()*26)];
}
for (var i=0; i<500; i++) {
input2 += ch[Math.floor(Math.random()*26)];
}
for (var i=0; i<10000; i++) {
input3 += ch[Math.floor(Math.random()*26)];
}
</script>
<script language="javascript" src="//rawgithub.com/sebastian-software/core/master/source/class/core/util/Base64.js"></script>
<script language="javascript" src="//rawgithub.com/sebastian-software/core/master/source/class/core/util/TextCompressor.js"></script>
      
<script>
Benchmark.prototype.teardown = function() {
  console.log("Size of compressed string: ", comp1.length + "/" + comp2.length + "/" + comp3.length);

};
</script>

Preparation code output

<script language="javascript"> window.core = { Module : function(name, obj) { var cur = window; name = name.split("."); while (name.length > 1) { var n = name.shift(); if (!cur[n]) cur[n] = {}; cur = cur[n]; } cur[name[0]] = obj; } }; var glob = window; core.Module("core.Main", { getGlobal : function() { return glob; } }); var input1 = ""; // 30 characters long var input2 = ""; // 500 characters long var input3 = ""; // 10000 characters long var ch = "abcdefghijklmnopqrstuvwxyz"; for (var i=0; i<30; i++) { input1 += ch[Math.floor(Math.random()*26)]; } for (var i=0; i<500; i++) { input2 += ch[Math.floor(Math.random()*26)]; } for (var i=0; i<10000; i++) { input3 += ch[Math.floor(Math.random()*26)]; } </script> <script language="javascript" src="//rawgithub.com/sebastian-software/core/master/source/class/core/util/Base64.js"></script> <script language="javascript" src="//rawgithub.com/sebastian-software/core/master/source/class/core/util/TextCompressor.js"></script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
TextCompressor
var comp1 = core.util.TextCompressor.compress(input1);
var orig1 = core.util.TextCompressor.decompress(comp1);

var comp2 = core.util.TextCompressor.compress(input2);
var orig2 = core.util.TextCompressor.decompress(comp2);

var comp3 = core.util.TextCompressor.compress(input3);
var orig3 = core.util.TextCompressor.decompress(comp3);
pending…
LZ
var comp1 = LZString.compressToUTF16(input1);
var orig1 = LZString.decompressFromUTF16(comp1);

var comp2 = LZString.compressToUTF16(input2);
var orig2 = LZString.decompressFromUTF16(comp2);

var comp3 = LZString.compressToUTF16(input3);
var orig3 = LZString.decompressFromUTF16(comp3);
pending…

Compare results of other browsers

Revisions

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

1 Comment

mcdit commented :

OPERA !!!!