diff --git a/.github/workflows/bench.yaml b/.github/workflows/bench.yaml index ff02740..19ab69e 100644 --- a/.github/workflows/bench.yaml +++ b/.github/workflows/bench.yaml @@ -35,10 +35,7 @@ jobs: bash build.sh - name: Run bench and graph results working-directory: ./bench - run: | - node run.js - node bench.js - node graph.js + run: bash bench.sh - uses: chrislennon/action-aws-cli@v1.1 - name: Upload to S3 env: diff --git a/bench/.gitignore b/bench/.gitignore index cda332c..85c67de 100644 --- a/bench/.gitignore +++ b/bench/.gitignore @@ -1,7 +1,7 @@ /hyperbuild-bench/Cargo.lock /hyperbuild-bench/target/ /min/ -/results/ +/results*/ node_modules/ package-lock.json perf.data* diff --git a/bench/README.md b/bench/README.md index 40407da..9738202 100644 --- a/bench/README.md +++ b/bench/README.md @@ -31,7 +31,7 @@ The [Node.js version of hyperbuild](../nodejs) is tested against [html-minfier]( 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: +On this [project's README](../README.md), average graphs are shown. Graphs showing per-test results are shown below: Chart showing speed of HTML minifiers per test Chart showing effectiveness of HTML minifiers per test @@ -48,9 +48,9 @@ Make sure to install the dependencies listed in [package.json](./package.json) b Run [build.sh](./build.sh) to build hyperbuild-nodejs with the local hyperbuild. -Run [run.js](./run.js) to run each HTML minifier against each test and record the minified size results. This will also output the minified files in `min` if inspection of minified outputs is necessary. [compare.sh](./compare.sh) is a useful script for viewing a character-by-character diff between the minified outputs of hyperbuild and html-minifier for a specific test. Pass the test's file name as the first argument. +Run [sizes.js](sizes.js) to run each HTML minifier against each test and record the minified size results. This will also output the minified files in `min` if inspection of minified outputs is necessary. [compare.sh](./compare.sh) is a useful script for viewing a character-by-character diff between the minified outputs of hyperbuild and html-minifier for a specific test. Pass the test's file name as the first argument. -Run [bench.js](./bench.js) to benchmark the performance of each HTML minifier against each test and record the op/s results. +Run [speeds.js](./speeds.js) to benchmark the performance of each HTML minifier against each test and record the op/s results. Run [graph.js](./graph.js) to render graphs from recorded speed and size results in the `results` folder. @@ -67,9 +67,4 @@ It takes two arguments: The results will be written to stdout as a JSON object, where properties are the test file names and values are the operations per second. -Profiling hyperbuild can be done on Linux by using `perf`, for example: - -```bash -perf record -g hyperbuild-bench/target/release/hyperbuild-bench --tests tests --iterations 1000 -perf report -``` +Profiling hyperbuild can be done on Linux by using [profile.sh](./profile.sh), which uses `perf`. The generated report can be used using `perf report`. diff --git a/bench/bench.sh b/bench/bench.sh new file mode 100644 index 0000000..1e7d211 --- /dev/null +++ b/bench/bench.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -e +shopt -s nullglob + +for i in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do + echo performance | sudo tee /sys/devices/system/cpu/cpu"$i"/cpufreq/scaling_governor +done + +node sizes.js +sudo nice -n -20 taskset -c 1 node speeds.js +sudo chown -R "$USER:$USER" results +node graph.js diff --git a/bench/profile.sh b/bench/profile.sh new file mode 100644 index 0000000..e55835e --- /dev/null +++ b/bench/profile.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e +shopt -s nullglob + +for i in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do + echo performance | sudo tee /sys/devices/system/cpu/cpu"$i"/cpufreq/scaling_governor +done + +rm -f perf.data +sudo perf record -g nice -n -20 taskset -c 1 hyperbuild-bench/target/release/hyperbuild-bench --tests tests --iterations 512 +sudo chown "$USER:$USER" perf.data diff --git a/bench/run.js b/bench/sizes.js similarity index 100% rename from bench/run.js rename to bench/sizes.js diff --git a/bench/bench.js b/bench/speeds.js similarity index 100% rename from bench/bench.js rename to bench/speeds.js