From dd325362f9920102779a592e2e53fdcf21d27d2c Mon Sep 17 00:00:00 2001 From: harttle Date: Sun, 3 Oct 2021 19:07:51 +0800 Subject: [PATCH] chore: perf check, will fail if regression > 3% --- .github/workflows/check.yml | 5 ++++- benchmark/diff.js | 3 +++ bin/perf-diff.sh | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index a69e17811..f08d07a65 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -24,4 +24,7 @@ jobs: - name: Coverage uses: coverallsapp/github-action@v1.1.2 with: - github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Performance + run: | + npm run perf:diff \ No newline at end of file diff --git a/benchmark/diff.js b/benchmark/diff.js index 22c38b702..ac380f7f8 100755 --- a/benchmark/diff.js +++ b/benchmark/diff.js @@ -45,3 +45,6 @@ const diff = (localResult.perf - latestResult.perf) / latestResult.perf console.log(`Local: ${localResult.perf.toFixed(3)} ops/s (${localResult.cycles} cycles)`) console.log(`Latest: ${latestResult.perf.toFixed(3)} ops/s (${latestResult.cycles} cycles)`) console.log(`Diff: ${(diff * 100).toFixed(3)}%`) + +const THRESHOLD_PERCENT = -3 +process.exit(diff * 100 < THRESHOLD_PERCENT ? 1 : 0) diff --git a/bin/perf-diff.sh b/bin/perf-diff.sh index fbd1cb9aa..eae3fd28d 100755 --- a/bin/perf-diff.sh +++ b/bin/perf-diff.sh @@ -13,4 +13,4 @@ if [ ! -f $FILE_LOCAL ]; then BUNDLES=cjs npm run build:dist fi -node benchmark/diff.js $FILE_LOCAL $FILE_LATEST +exec node benchmark/diff.js $FILE_LOCAL $FILE_LATEST