Skip to content

Commit 7286dc8

Browse files
authored
JSO Benchmarks (#307)
1 parent 8b7a6b7 commit 7286dc8

3 files changed

Lines changed: 111 additions & 0 deletions

File tree

.github/workflows/jsobmarks.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: JSOBenchmarks
2+
on:
3+
pull_request:
4+
types: [labeled, opened, synchronize, reopened]
5+
workflow_call:
6+
7+
jobs:
8+
bmark:
9+
name: Julia ${{ matrix.version }} - macOS - ${{ matrix.arch }} - ${{ github.event_name }}
10+
if: github.event_name == 'workflow_call' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run benchmarks'))
11+
# FIXME: should run on hosted runner
12+
runs-on: macOS-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
version:
17+
- 1
18+
arch:
19+
- aarch64
20+
steps:
21+
- uses: actions/checkout@v6
22+
with:
23+
fetch-depth: 0
24+
- uses: julia-actions/setup-julia@v2
25+
with:
26+
version: ${{ matrix.version }}
27+
arch: ${{ matrix.arch }}
28+
- uses: julia-actions/julia-buildpkg@v1
29+
# FIXME: register JSOBenchmarks
30+
- name: Installing non-registered dependencies
31+
run: |
32+
using Pkg
33+
pkg1 = PackageSpec(url = "https://github.com/JuliaSmoothOptimizers/JSOBenchmarks.jl.git", rev = "main")
34+
pkg_list = [pkg1]
35+
Pkg.add(pkg_list)
36+
shell: julia --project=benchmark --color=yes {0}
37+
- name: Install benchmark dependencies
38+
run: julia --project=benchmark -e 'using Pkg; Pkg.instantiate()'
39+
- name: Sanitize project name
40+
id: sanitize
41+
run: echo "REPONAME=${{ github.event.repository.name }}" | sed -e 's/\.jl$//' >> $GITHUB_OUTPUT
42+
- name: Run benchmarks
43+
run: julia --project=benchmark -e 'using JSOBenchmarks; run_benchmarks("${{ steps.sanitize.outputs.REPONAME }}", "benchmark", reference_branch = "main")'
44+
env:
45+
GITHUB_AUTH: ${{ secrets.GIST_TOKEN }}
46+
# - name: Post benchmark results in PR
47+
# uses: thollander/actions-comment-pull-request@v2
48+
# with:
49+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
# message: "Full benchmark results stored as artifacts. Summary: ${{ secrets.BMARK_GIST_URL }}"
51+
- name: Build comment
52+
id: build-comment
53+
uses: actions/github-script@v6
54+
with:
55+
github-token: ${{ github.token }}
56+
result-encoding: string
57+
script: |
58+
const fs = require('fs');
59+
return fs.readFileSync("${{ github.workspace }}/bmark_${{ github.sha }}.md", "utf8").toString();
60+
- name: Comment in PR
61+
uses: thollander/actions-comment-pull-request@v2
62+
with:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
message: ${{ steps.build-comment.outputs.result }}
65+
# - name: Upload benchmark plots
66+
# uses: edunad/actions-image@v2.0.0
67+
# with:
68+
# path: "./*.png"
69+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
# title: "Benchmarks at a Glance"
71+
# annotationLevel: "notice"
72+
- name: Upload artifacts
73+
uses: actions/upload-artifact@v7
74+
with:
75+
name: jso-benchmarks
76+
path: |
77+
profiles_this_commit_vs_reference_*.svg
78+
*_vs_reference_*.jld2
79+
bmark_*.md
80+
reference.md
81+
judgement_*.md

benchmark/Project.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[deps]
2+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
3+
JSOBenchmarks = "9410e2bb-e8e7-4fa0-9768-685b196f59b5"
4+
PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d"
5+
RegularizedOptimization = "20620ad1-4fe4-4467-ae46-fb087718fe7b"
6+
RegularizedProblems = "ea076b23-609f-44d2-bb12-a4ae45328278"
7+
8+
[compat]
9+
julia = "1"
10+
BenchmarkTools = "1"
11+
PkgBenchmark = "0.2"
12+
# JSOBenchmarks = "0.1"
13+
RegularizedOptimization = "0.2"
14+
RegularizedProblems = "0.1"

benchmark/benchmarks.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using BenchmarkTools
2+
using RegularizedProblems, RegularizedOptimization
3+
4+
const SUITE = BenchmarkGroup()
5+
6+
bpdn_l0, _ = setup_bpdn_l0()
7+
bpdn_l1, _ = setup_bpdn_l1()
8+
bpdn_B0, _ = setup_bpdn_B0()
9+
10+
for solver (R2,)
11+
solver_name = string(solver)
12+
SUITE[solver_name] = BenchmarkGroup()
13+
SUITE[solver_name]["bpdn_l0"] = @benchmarkable $solver($bpdn_l0)
14+
SUITE[solver_name]["bpdn_l1"] = @benchmarkable $solver($bpdn_l1)
15+
SUITE[solver_name]["bpdn_B0"] = @benchmarkable $solver($bpdn_B0)
16+
end

0 commit comments

Comments
 (0)