Skip to content

Commit 7b9940f

Browse files
committed
added: benchmarking workflow with github actions
1 parent 2ec4d36 commit 7b9940f

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

.github/workflows/Benchmark.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Run benchmarks
2+
on:
3+
pull_request:
4+
# Only trigger the benchmark job when you add `run benchmark` label to the PR
5+
types: [labeled, opened, synchronize, reopened]
6+
concurrency:
7+
# Skip intermediate builds: always.
8+
# Cancel intermediate builds: only if it is a pull request build.
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
11+
jobs:
12+
Benchmark:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
pull-requests: write
16+
actions: write # needed to allow julia-actions/cache to proactively delete old caches that it has created
17+
contents: read
18+
if: contains(github.event.pull_request.labels.*.name, 'benchmark')
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: julia-actions/setup-julia@latest
22+
- name: Cache artifacts
23+
uses: actions/cache@v4
24+
env:
25+
cache-name: cache-artifacts
26+
with:
27+
path: ~/.julia/artifacts
28+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
29+
restore-keys: |
30+
${{ runner.os }}-test-${{ env.cache-name }}-
31+
${{ runner.os }}-test-
32+
${{ runner.os }}-
33+
- name: Install dependencies
34+
run: julia -e 'using Pkg; pkg"add JSON PkgBenchmark [email protected]"'
35+
- name: Run benchmarks
36+
run: julia benchmark/run_benchmarks.jl
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LocalPreferences.toml
66
*.cov
77
docs/Manifest.toml
88
lcov.info
9+
benchmark/Manifest.toml

benchmark/Project.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[deps]
2+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
3+
DAQP = "c47d62df-3981-49c8-9651-128b1cd08617"
4+
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
5+
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
6+
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
7+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
8+
MadNLP = "2621e9c9-9eb4-46b1-8089-e8c72242dfb6"
9+
ModelPredictiveControl = "61f9bdb8-6ae4-484a-811f-bbf86720c31c"
10+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
11+
SparseConnectivityTracer = "9f842d2f-2579-4b1d-911e-f412cf18a3f5"
12+
SparseMatrixColorings = "0a514795-09f3-496d-8182-132a7b665d35"

benchmark/benchmark.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using BenchmarkTools
2+
using Random
3+
4+
const SUITE = BenchmarkGroup()
5+
6+
SUITE["utf8"] = BenchmarkGroup(["string", "unicode"])
7+
teststr = String(join(rand(MersenneTwister(1), 'a':'d', 10^4)))
8+
SUITE["utf8"]["replace"] = @benchmarkable replace($teststr, "a" => "b")
9+
SUITE["utf8"]["join"] = @benchmarkable join($teststr, $teststr)
10+
SUITE["utf8"]["plots"] = BenchmarkGroup()
11+
12+
SUITE["trigonometry"] = BenchmarkGroup(["math", "triangles"])
13+
SUITE["trigonometry"]["circular"] = BenchmarkGroup()
14+
for f in (sin, cos, tan)
15+
for x in (0.0, pi)
16+
SUITE["trigonometry"]["circular"][string(f), x] = @benchmarkable ($f)($x)
17+
end
18+
end
19+
20+
SUITE["trigonometry"]["hyperbolic"] = BenchmarkGroup()
21+
for f in (sin, cos, tan)
22+
for x in (0.0, pi)
23+
SUITE["trigonometry"]["hyperbolic"][string(f), x] = @benchmarkable ($f)($x)
24+
end
25+
end

0 commit comments

Comments
 (0)