rJSmin - Benchmark

The following numbers have been measured with the bench.py script provided in the source distribution. Since the numbers don’t vary much between python minor releases (e.g. 2.6 vs 2.7), only the benchmarks for 2.7 and 3.2 are given below. The docs/BENCHMARKS file in the source distribution contains the full list.

Here’s the list of benchmarked implementations:

  • Simple port is the original jsmin.py port by Baruch Even
  • jsmin 2.0.2 is a speed-refactored python port by Dave St.Germain
  • slimit 0.6 is a minifier based on a parse/generate-iteration. It’s available for python 2 only.
  • slimit 0.6 (mangle) is slimit 0.6 with name mangeling enabled
  • rJSmin is this very project
  • _rJSmin is the C reimplementation of rJSmin

Note that jsmin 2.0.2 and slimit produce output different from the original jsmin.c. Also the simple port was modified to use cStringIO if available (it’s faster then) or io (for python 3).

And here’s a list of the benchmarked javascript files:

  • apiviewer is a file from the qooxdoo framework. Very big and already compressed.
  • jquery is jquery-1.7.1.js; the uncompressed development download.
  • knockout is knockout-2.0.0.js, the compressed download.
  • markermanager is the V3 port of the google maps markermanager.

Inside the parentheses are size information in KiB (actually: number of characters/1024). The sign behind the size value denotes the size difference in relation to the simple port (i.e. jsmin itself). Note that “knockout” contains ‘+ ++‘ sequences, so rjsmin produces results bigger than the simple port (which collapses those).

Python 3.2.2

Name apiviewer (953.2) jquery (242.4)
Simple Port 3001.55 ms (951.5 *) 653.28 ms (135.9 *)
jsmin 2.0.2 531.25 ms (951.4 <) 122.38 ms (136.5 >)
slimit 0.6 n/a n/a
slimit 0.6 (mangle) n/a n/a
rJSmin 83.96 ms (951.5 =) 120.19 ms (135.9 =)
_rJSmin 3.36 ms (951.5 =) 1.34 ms (135.9 =)
Name knockout (38.9) markermanager (28.6)
Simple Port 118.51 ms (38.6 *) 59.56 ms (11.6 *)
jsmin 2.0.2 22.09 ms (38.6 >) 12.45 ms (11.6 >)
slimit 0.6 n/a n/a
slimit 0.6 (mangle) n/a n/a
rJSmin 4.40 ms (38.6 >) 7.19 ms (11.6 =)
_rJSmin 0.14 ms (38.6 >) 0.10 ms (11.6 =)

Python 2.7.2

Name apiviewer (953.2) jquery (242.4)
Simple Port 3525.31 ms (951.5 *) 742.71 ms (135.9 *)
jsmin 2.0.2 724.06 ms (951.4 <) 170.65 ms (136.5 >)
slimit 0.6 16649.53 ms (944.3 <) 2270.43 ms (134.0 <)
slimit 0.6 (mangle) 20662.24 ms (922.8 <) 2666.06 ms ( 95.0 <)
rJSmin 68.52 ms (951.5 =) 110.20 ms (135.9 =)
_rJSmin 3.19 ms (951.5 =) 1.28 ms (135.9 =)
Name knockout (38.9) markermanager (28.6)
Simple Port 142.17 ms (38.6 *) 67.97 ms (11.6 *)
jsmin 2.0.2 31.65 ms (38.6 >) 16.73 ms (11.6 >)
slimit 0.6 864.39 ms (39.0 >) 172.83 ms (11.5 <)
slimit 0.6 (mangle) 1056.11 ms (38.9 >) 213.42 ms ( 8.6 <)
rJSmin 3.81 ms (38.6 >) 6.64 ms (11.6 =)
_rJSmin 0.14 ms (38.6 >) 0.10 ms (11.6 =)