Skip to content

Instantly share code, notes, and snippets.

@rsp
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsp/b455f65c78eba41479a8 to your computer and use it in GitHub Desktop.
Save rsp/b455f65c78eba41479a8 to your computer and use it in GitHub Desktop.

Gzipped benchmarks for HTML Minifier

Note: this is a temporary solution for anyone who would like to see statistics of minification+gzipping vs. just gzipping the HTML before the gzipped stats are properly integrated into the main benchmark.

How to run the benchmarks from https://github.com/rsp/html-minifier/tree/gzip-benchmark

Clone the repo:

git clone https://github.com/rsp/html-minifier.git
cd html-minifier

Use the gzip-benchmark branch:

git checkout gzip-benchmark

Install or link dependencies:

npm install

Run benchmarks for minified HTML:

node benchmark.js

Run benchmarks for minified and gzipped HTML:

node gzip-benchmark.js
@simevidas
Copy link

Could you post screens of the tables? I get a type error when running gzip-benchmark.js.

TypeError: Cannot read property 'size' of undefined
at d:\Projects\html-minifier\gzip-benchmark.js:60:29
at Object.oncomplete (fs.js:107:15)

@mathiasbynens
Copy link

@simevidas:

$ node benchmark.js
┌────────────────────┬─────────────────────────┬─────────────────────────┬────────────────────┬────────────────────┐
│ File               │ Before                  │ After                   │ Savings            │ Time               │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ html-minifier      │ 49978 (48.81KB)         │ 38237 (37.34KB)         │ 23.49% (11.47KB)   │ 292ms              │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ abc                │ 93187 (91.00KB)         │ 72111 (70.42KB)         │ 22.62% (20.58KB)   │ 705ms              │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ newyorktimes       │ 134565 (131.41KB)       │ 112653 (110.01KB)       │ 16.28% (21.40KB)   │ 882ms              │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ google             │ 136320 (133.13KB)       │ 129279 (126.25KB)       │ 5.17% (6.88KB)     │ 950ms              │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ msn                │ 160454 (156.69KB)       │ 136255 (133.06KB)       │ 15.08% (23.63KB)   │ 961ms              │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ es6-table          │ 120768 (117.94KB)       │ 81839 (79.92KB)         │ 32.23% (38.02KB)   │ 1078ms             │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ amazon             │ 251828 (245.93KB)       │ 211393 (206.44KB)       │ 16.06% (39.49KB)   │ 1307ms             │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ stackoverflow      │ 205280 (200.47KB)       │ 163421 (159.59KB)       │ 20.39% (40.88KB)   │ 2804ms             │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ wikipedia          │ 411051 (401.42KB)       │ 389761 (380.63KB)       │ 5.18% (20.79KB)    │ 7120ms             │
└────────────────────┴─────────────────────────┴─────────────────────────┴────────────────────┴────────────────────┘
Average savings: 24.79%
$ node gzip-benchmark.js
┌────────────────────┬─────────────────────────┬─────────────────────────┬────────────────────┬────────────────────┐
│ File               │ Before                  │ After                   │ Savings            │ Time               │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ html-minifier      │ 10192 (9.95KB)          │ 8778 (8.57KB)           │ 13.87% (1.38KB)    │ 345ms              │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ abc                │ 17087 (16.69KB)         │ 14274 (13.94KB)         │ 16.46% (2.75KB)    │ 689ms              │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ newyorktimes       │ 29950 (29.25KB)         │ 25922 (25.31KB)         │ 13.45% (3.93KB)    │ 874ms              │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ google             │ 40189 (39.25KB)         │ 38855 (37.94KB)         │ 3.32% (1.30KB)     │ 980ms              │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ msn                │ 42206 (41.22KB)         │ 37966 (37.08KB)         │ 10.05% (4.14KB)    │ 1020ms             │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ es6-table          │ 6036 (5.89KB)           │ 5255 (5.13KB)           │ 12.94% (0.76KB)    │ 1073ms             │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ amazon             │ 57514 (56.17KB)         │ 50189 (49.01KB)         │ 12.74% (7.15KB)    │ 1355ms             │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ stackoverflow      │ 32625 (31.86KB)         │ 30621 (29.90KB)         │ 6.14% (1.96KB)     │ 2915ms             │
├────────────────────┼─────────────────────────┼─────────────────────────┼────────────────────┼────────────────────┤
│ wikipedia          │ 82028 (80.11KB)         │ 80663 (78.77KB)         │ 1.66% (1.33KB)     │ 7207ms             │
└────────────────────┴─────────────────────────┴─────────────────────────┴────────────────────┴────────────────────┘

Average savings: 2.75%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment