Skip to content

Commit

Permalink
Add benchmark tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
albertomercurio committed May 4, 2024
1 parent 0f43c6e commit 8867987
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/Benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Benchmark Tracking
on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: write
deployments: write

concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
benchmark:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '1'
arch: x64
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- name: Run benchmark
run: |
cd benchmarks
julia --project --threads=2 --color=yes -e '
using Pkg;
Pkg.develop(PackageSpec(path=joinpath(pwd(), "..")));
Pkg.instantiate();
include("runbenchmarks.jl")'
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: Julia benchmark result
tool: "julia"
output-file-path: benchmarks/benchmarks_output.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: ${{ github.event_name != 'pull_request' }}
# 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: "@ktrz,@findmyway"
1 change: 1 addition & 0 deletions benchmarks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/benchmarks_output.json
2 changes: 2 additions & 0 deletions benchmarks/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
29 changes: 29 additions & 0 deletions benchmarks/runbenchmarks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using BenchmarkTools
using QuantumToolbox

fib(n) = n <= 1 ? 1 : fib(n - 2) + fib(n - 1)

suite = BenchmarkGroup()

suite["steadystate"] = BenchmarkGroup(["steadystate"])


## steadystate ##

N = 50
Δ = 0.1
F = 2
γ = 1
a = destroy(N)
H = Δ * a' * a + F * (a + a')
c_ops = [sqrt(γ) * a]

suite["steadystate"]["driven-dissipative harmonic oscillator"] = @benchmarkable steadystate($H, $c_ops)

## end ##


tune!(suite)
results = run(suite, verbose = true)

BenchmarkTools.save("benchmarks_output.json", mean(results))

0 comments on commit 8867987

Please sign in to comment.