Benchmark with workflow instead

This commit is contained in:
Wilson Lin 2020-01-26 16:38:14 +13:00
parent ead4917fb7
commit 26f5aa4cf6
11 changed files with 60 additions and 308 deletions

48
.github/workflows/bench.yaml vendored Normal file
View File

@ -0,0 +1,48 @@
name: Run benchmark and upload results
on:
create:
tags:
- 'v*'
jobs:
bench:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Get version
id: version
shell: bash
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}
- name: Set up Node.js
uses: actions/setup-node@master
with:
node-version: 10.x
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Set up Node.js module
working-directory: ./nodejs
run: npm install
- name: Build bench
working-directory: ./bench
run: |
sudo apt install -y build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
npm install
bash build.sh
- name: Run bench and graph results
working-directory: ./bench
run: |
node run.js
node bench.js
node graph.js
- uses: chrislennon/action-aws-cli@v1.1
- name: Upload to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-west-2
run: aws s3 cp ./bench/results/ s3://${{ secrets.AWS_S3_BUCKET }}/hyperbuild/bench/${{ steps.version.outputs.VERSION }}/ --recursive

View File

@ -17,7 +17,7 @@ Available as:
Speed and effectiveness of Node.js version compared to [html-minfier](https://github.com/kangax/html-minifier) and [minimize](https://github.com/Swaagie/minimize). See [bench](./bench) folder for more details.
<img width="435" alt="Chart showing speed of HTML minifiers" src="./bench/results/average-speeds.png"> <img width="435" alt="Chart showing effectiveness of HTML minifiers" src="./bench/results/average-sizes.png">
<img width="435" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/hyperbuild/bench/0.0.36/average-speeds.png"> <img width="435" alt="Chart showing effectiveness of HTML minifiers" src="https://wilsonl.in/hyperbuild/bench/0.0.36/average-sizes.png">
## Usage

View File

@ -2,7 +2,7 @@
This folder contains scripts used to test the performance and effectiveness of hyperbuild, for guided optimisation and/or comparisons.
It also contains a set of common web pages as tests and the benchmarking results of running various HTML minifiers on them. Tests and results are committed to the repository for historical tracking and reproducibility.
It also contains a set of common web pages as tests for benchmarking.
## Comparison
@ -33,7 +33,7 @@ For more information on how the tests are fetched, see [fetch.js](./fetch.js).
The results are available in the [results](./results) folder. On this [project's README](../README.md), average graphs are shown. Graphs showing per-test results are shown below:
<img width="435" alt="Chart showing speed of HTML minifiers per test" src="./results/speeds.png"> <img width="435" alt="Chart showing effectiveness of HTML minifiers per test" src="./results/sizes.png">
<img width="435" alt="Chart showing speed of HTML minifiers per test" src="https://wilsonl.in/hyperbuild/bench/0.0.36/speeds.png"> <img width="435" alt="Chart showing effectiveness of HTML minifiers per test" src="https://wilsonl.in/hyperbuild/bench/0.0.36/sizes.png">
Since speed depends on the input, speed charts show performance relative to hyperbuild-nodejs as a percentage.

View File

@ -1,7 +1,8 @@
const minifiers = require('./minifiers');
const mkdirp = require('mkdirp');
const tests = require('./tests');
const {join} = require('path');
const {readFileSync, writeFileSync} = require('fs');
const minifiers = require('./minifiers');
const tests = require('./tests');
const RESULTS_DIR = join(__dirname, 'results');
const SPEEDS_JSON = join(RESULTS_DIR, 'speeds.json');
@ -14,6 +15,8 @@ const AVERAGE_SIZES_GRAPH = join(RESULTS_DIR, 'average-sizes.png');
const minifierNames = Object.keys(minifiers);
const testNames = tests.map(t => t.name);
mkdirp.sync(RESULTS_DIR);
module.exports = {
writeSpeedResults(speeds) {
writeFileSync(SPEEDS_JSON, JSON.stringify(speeds, null, 2));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

View File

@ -1,236 +0,0 @@
{
"Amazon": {
"original": {
"absolute": 368816,
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 353461,
"relative": 0.9583667736757624
},
"html-minifier": {
"absolute": 355185,
"relative": 0.9630411912715283
},
"minimize": {
"absolute": 359912,
"relative": 0.9758578803522624
}
},
"BBC": {
"original": {
"absolute": 246217,
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 231701,
"relative": 0.9410438759305816
},
"html-minifier": {
"absolute": 234306,
"relative": 0.9516239739741772
},
"minimize": {
"absolute": 238547,
"relative": 0.96884861727663
}
},
"Bing": {
"original": {
"absolute": 92029,
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 90455,
"relative": 0.9828966956068196
},
"html-minifier": {
"absolute": 90599,
"relative": 0.9844614197698551
},
"minimize": {
"absolute": 91020,
"relative": 0.98903606471873
}
},
"Bootstrap": {
"original": {
"absolute": 309742,
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 270733,
"relative": 0.8740597012997915
},
"html-minifier": {
"absolute": 277911,
"relative": 0.8972338268623564
},
"minimize": {
"absolute": 278990,
"relative": 0.900717371231541
}
},
"Coding Horror": {
"original": {
"absolute": 84628,
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 79638,
"relative": 0.9410360637141372
},
"html-minifier": {
"absolute": 81446,
"relative": 0.9624001512501772
},
"minimize": {
"absolute": 81844,
"relative": 0.9671030864489294
}
},
"ECMA-262": {
"original": {
"absolute": 6316389,
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 5739749,
"relative": 0.9087073326231174
},
"html-minifier": {
"absolute": 5785725,
"relative": 0.9159861750123369
},
"minimize": {
"absolute": 5799350,
"relative": 0.9181432619175292
}
},
"Google": {
"original": {
"absolute": 197290,
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 196577,
"relative": 0.9963860307162046
},
"html-minifier": {
"absolute": 196600,
"relative": 0.9965026103705206
},
"minimize": {
"absolute": 196776,
"relative": 0.997394698160069
}
},
"Hacker News": {
"original": {
"absolute": 34021,
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 28114,
"relative": 0.826371946738779
},
"html-minifier": {
"absolute": 29086,
"relative": 0.8549425354927839
},
"minimize": {
"absolute": 30318,
"relative": 0.8911554628023868
}
},
"NY Times": {
"original": {
"absolute": 1267834,
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 1263048,
"relative": 0.9962250578545772
},
"html-minifier": {
"absolute": 1263150,
"relative": 0.9963055100273379
},
"minimize": {
"absolute": 1264354,
"relative": 0.997255161164632
}
},
"Reddit": {
"original": {
"absolute": 651577,
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 647965,
"relative": 0.9944565262432529
},
"html-minifier": {
"absolute": 647822,
"relative": 0.9942370587052644
},
"minimize": {
"absolute": 648422,
"relative": 0.9951579015219997
}
},
"Stack Overflow": {
"original": {
"absolute": 112229,
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 86589,
"relative": 0.771538550641991
},
"html-minifier": {
"absolute": 88366,
"relative": 0.7873722478147359
},
"minimize": {
"absolute": 89682,
"relative": 0.7990982722825651
}
},
"Twitter": {
"original": {
"absolute": 315154,
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 265212,
"relative": 0.8415314417713244
},
"html-minifier": {
"absolute": 266639,
"relative": 0.8460593868394499
},
"minimize": {
"absolute": 307860,
"relative": 0.9768557594065124
}
},
"Wikipedia": {
"original": {
"absolute": 1411155,
"relative": 1
},
"hyperbuild-nodejs": {
"absolute": 1316235,
"relative": 0.9327359503385525
},
"html-minifier": {
"absolute": 1327244,
"relative": 0.940537361239552
},
"minimize": {
"absolute": 1369798,
"relative": 0.9706928012868891
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

View File

@ -1,67 +0,0 @@
{
"Amazon": {
"hyperbuild-nodejs": 497.0684008679241,
"html-minifier": 36.28930820880813,
"minimize": 114.18558697357896
},
"BBC": {
"hyperbuild-nodejs": 530.356838970197,
"html-minifier": 48.63263590575628,
"minimize": 160.9462295874063
},
"Bing": {
"hyperbuild-nodejs": 2134.6747025695076,
"html-minifier": 221.00143110816123,
"minimize": 551.4842672816046
},
"Bootstrap": {
"hyperbuild-nodejs": 271.35337683063364,
"html-minifier": 7.97192942546144,
"minimize": 22.302011949055192
},
"Coding Horror": {
"hyperbuild-nodejs": 1019.5233646175254,
"html-minifier": 49.28536290527941,
"minimize": 187.54666897520576
},
"ECMA-262": {
"hyperbuild-nodejs": 15.344258383194457,
"html-minifier": 0.44536511869011475,
"minimize": 1.3342793943531839
},
"Google": {
"hyperbuild-nodejs": 1827.5416680815183,
"html-minifier": 242.58427545496446,
"minimize": 579.275465488081
},
"Hacker News": {
"hyperbuild-nodejs": 2071.747702993173,
"html-minifier": 73.41021778919102,
"minimize": 270.4509347009959
},
"NY Times": {
"hyperbuild-nodejs": 276.16242726823117,
"html-minifier": 36.853296596407354,
"minimize": 86.40323822747456
},
"Reddit": {
"hyperbuild-nodejs": 404.3269179058215,
"html-minifier": 44.98344851074736,
"minimize": 124.11335556541236
},
"Stack Overflow": {
"hyperbuild-nodejs": 820.8141564896657,
"html-minifier": 41.63919304297733,
"minimize": 161.27817560216315
},
"Twitter": {
"hyperbuild-nodejs": 280.20971195021036,
"html-minifier": 37.298870434334766,
"minimize": 166.8418036944524
},
"Wikipedia": {
"hyperbuild-nodejs": 54.272192449450806,
"html-minifier": 2.8349496354931727,
"minimize": 8.748906528012489
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

View File

@ -89,6 +89,10 @@ for (const f of ["README.md"]) {
replaceInFile(f, /(wilsonl\.in\/hyperbuild\/bin\/)\d+\.\d+\.\d+/g, `$1${NEW_VERSION}`);
}
for (const f of ["README.md", "bench/README.md"]) {
replaceInFile(f, /(wilsonl\.in\/hyperbuild\/bench\/)\d+\.\d+\.\d+/g, `$1${NEW_VERSION}`);
}
cmd('cargo', 'generate-lockfile');
cmd('git', 'add', '-A');
cmd('git', 'commit', '-m', NEW_VERSION);