rJSmin - Benchmark

The following numbers have been measured with the bench package provided in the source distribution. Since the numbers don’t vary much between python minor releases (e.g. 3.3 vs 3.4), only one benchmark per major version is given below. The docs/BENCHMARKS file in the source distribution contains a more comprehensive list.

Here’s the list of benchmarked implementations:

Simple port
The original jsmin.py port by Baruch Even
jsmin 2.0.9
A speed-refactored python port by Dave St.Germain. There are some spikes in lower Python 3 versions (especially for the big file [apiviewer.js]).
rJSmin
this very project
_rJSmin
The C reimplementation of rJSmin

Note that the various implementations produce output different from the original jsmin.c for one reason or another. 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.
  • bootstrap is the popular twitter toolkit, version 2.0.4
  • DateTimeShortcuts is part of the Django admin interface (1.8.5)
  • 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 [1]. The sign behind the size value denotes the size difference in relation to the simple port (i.e. jsmin itself).

[1]Bytes / 1024 for Python 2 and Code Points / 1024 for Python 3

Python 3.5.0

Name apiviewer (953.2) bootstrap (49.0)
Simple Port 1417.14 ms (951.5 *) 58.49 ms (26.4 *)
jsmin 2.0.9 1682.43 ms (951.5 >) 23.18 ms (26.4 >)
rJSmin 36.38 ms (951.5 =) 8.93 ms (26.4 >)
_rJSmin 1.81 ms (951.5 =) 0.13 ms (26.4 >)
Name DateTimeShortcuts (18.3) jquery (242.4)
Simple Port 21.83 ms (10.2 *) 306.41 ms (135.9 *)
jsmin 2.0.9 8.87 ms (10.3 >) 156.45 ms (136.8 >)
rJSmin 2.42 ms (10.2 >) 61.57 ms (135.9 =)
_rJSmin 0.05 ms (10.2 >) 0.83 ms (135.9 =)
Name knockout (38.9) markermanager (28.6)
Simple Port 56.58 ms (38.6 *) 28.61 ms (11.6 *)
jsmin 2.0.9 25.53 ms (38.6 >) 11.74 ms (11.6 >)
rJSmin 1.88 ms (38.6 >) 3.81 ms (11.6 =)
_rJSmin 0.08 ms (38.6 >) 0.06 ms (11.6 =)

Python 2.7.10

Name apiviewer (953.2) bootstrap (49.0)
Simple Port 1838.28 ms (951.5 *) 73.95 ms (26.4 *)
jsmin 2.0.9 2031.25 ms (951.5 >) 31.02 ms (26.4 >)
rJSmin 44.39 ms (951.5 =) 9.36 ms (26.4 >)
_rJSmin 1.65 ms (951.5 =) 0.13 ms (26.4 >)
Name DateTimeShortcuts (18.3) jquery (242.4)
Simple Port 27.22 ms (10.2 *) 379.62 ms (135.9 *)
jsmin 2.0.9 11.76 ms (10.3 >) 207.60 ms (136.8 >)
rJSmin 2.57 ms (10.2 >) 65.50 ms (135.9 =)
_rJSmin 0.04 ms (10.2 >) 0.80 ms (135.9 =)
Name knockout (38.9) markermanager (28.6)
Simple Port 73.44 ms (38.6 *) 36.26 ms (11.6 *)
jsmin 2.0.9 34.63 ms (38.6 >) 15.54 ms (11.6 >)
rJSmin 2.05 ms (38.6 >) 4.06 ms (11.6 =)
_rJSmin 0.07 ms (38.6 >) 0.05 ms (11.6 =)