From 670faf275d4c4a2f450383f69bf1d29186fa1f10 Mon Sep 17 00:00:00 2001 From: Patrick Gingras <775.pg.12@gmail.com> Date: Thu, 31 Mar 2022 00:07:37 -0400 Subject: [PATCH] add benchmark action --- .github/workflows/benchmark.yaml | 52 ++++++++++++++++++++++++++++++++ Makefile | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/benchmark.yaml diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml new file mode 100644 index 0000000..58c174f --- /dev/null +++ b/.github/workflows/benchmark.yaml @@ -0,0 +1,52 @@ +# Do not run this workflow on pull request since this workflow has permission to modify contents. +on: + push: + branches: + - main + +permissions: + # deployments permission to deploy GitHub pages website + deployments: write + # contents permission to update benchmark contents in gh-pages branch + contents: write + +jobs: + benchmark: + name: Performance regression check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install libs + run: | + sudo apt-get update + sudo apt-get install build-essential libreadline-dev + - name: Compile + run: make TARGET=release + - name: Run benchmark + run: | + gettimems() { date '+%s%3N'; } + + NTIMES=3 + sum=0 + for i in $(seq $NTIMES); do + before=$(gettimems) + CBCVM_PATH=lib ./cbcvm bf.rbcvm bench.b + after=$(gettimems) + elapsed=$((after - before)) + sum=$((sum + elapsed)) + done + + avg=$((sum / NTIMES)) + printf '[{"name":"bench.b","value":%f,"unit":"ms"}]' avg > output.txt + # gh-pages branch is updated and pushed automatically with extracted benchmark data + - name: Store benchmark result + uses: benchmark-action/github-action-benchmark@v1 + with: + name: c-bytecode-vm benchmark + tool: customSmallerIsBetter + output-file-path: output.txt + # Access token to deploy GitHub Pages branch + github-token: ${{ secrets.GITHUB_TOKEN }} + # Push and deploy GitHub pages branch automatically + auto-push: true + comment-on-alert: true diff --git a/Makefile b/Makefile index d4a964c..0a5db17 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ endif endif cbcvm: *.c *.h modules/*.c modules/*.h - $(CC) $(CFLAGS) $(LDFLAGS) -o cbcvm *.c modules/*.c + $(CC) $(CFLAGS) -o cbcvm *.c modules/*.c $(LDFLAGS) # Generate a release binary using profile-guided optimization profile-opt: