From 1e30d448872fc9cf6a40e130de1025af9fb890c8 Mon Sep 17 00:00:00 2001 From: Nicholas Clarke Date: Wed, 24 Nov 2021 11:42:55 +0100 Subject: [PATCH] Add benchmark workflow. --- .github/tools/extract_criterion.jq | 3 ++ .github/workflows/bench.yml | 46 ++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .github/tools/extract_criterion.jq create mode 100644 .github/workflows/bench.yml diff --git a/.github/tools/extract_criterion.jq b/.github/tools/extract_criterion.jq new file mode 100644 index 00000000000..4fa33c09669 --- /dev/null +++ b/.github/tools/extract_criterion.jq @@ -0,0 +1,3 @@ +[.[2][] | +.reportName as $bench_name | +{ name: $bench_name, unit: "Nanoseconds", value: .reportAnalysis.anMean.estPoint, range: .reportAnalysis.anStdDev.estPoint }] diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml new file mode 100644 index 00000000000..d6e53c5e63c --- /dev/null +++ b/.github/workflows/bench.yml @@ -0,0 +1,46 @@ +name: Ledger Benchmarks +on: + push: + branches: + - master + - nc/bench-tx + +permissions: + contents: write + deployments: write + +jobs: + benchmark: + name: cardano-ledger benchmarks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v15 + with: + nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + substituters = https://hydra.iohk.io https://cache.nixos.org/ + - name: Build benchmarks + run: nix-build -A haskellPackages.cardano-ledger-test.components.benchmarks + - name: Run benchmark + run: | + cd libs/cardano-ledger-test + ../../result/bin/bench "applyTxBenchmarks" --json bench.json + - name: Transform results + run: | + nix-env -i jq -f '' + jq -f .github/tools/extract_criterion.jq < libs/cardano-ledger-test/bench.json > output.json + - name: Store benchmark result + uses: benchmark-action/github-action-benchmark@v1 + with: + name: Haskell Benchmark + tool: 'customSmallerIsBetter' + output-file-path: output.json + github-token: ${{ secrets.GITHUB_TOKEN }} + auto-push: true + # Show alert with commit comment on detecting possible performance regression + alert-threshold: '200%' + comment-on-alert: true + fail-on-alert: true + alert-comment-cc-users: '@nc6'