Skip to content

Commit 96a8ba4

Browse files
committed
Add benchmark
1 parent b193ff6 commit 96a8ba4

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-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+
3+
on:
4+
pull_request:
5+
paths:
6+
- "src/**"
7+
- "benchmark/**"
8+
- "Project.toml"
9+
- "benchmark/Project.toml"
10+
11+
permissions:
12+
contents: write
13+
issues: write
14+
pull-requests: write
15+
16+
concurrency:
17+
# Skip intermediate builds: always.
18+
# Cancel intermediate builds: only if it is a pull request build.
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
21+
22+
jobs:
23+
benchmark:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: julia-actions/setup-julia@latest
28+
with:
29+
version: 1
30+
- uses: julia-actions/julia-buildpkg@latest
31+
- name: Install dependencies
32+
run: julia -e 'using Pkg; pkg"add PkgBenchmark BenchmarkCI@0.1"'
33+
- name: Run benchmarks
34+
run: julia -e 'using BenchmarkCI; BenchmarkCI.judge(baseline="origin/main")'
35+
- name: Post results
36+
run: julia -e 'using BenchmarkCI; BenchmarkCI.postjudge()'
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

benchmark/Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[deps]
2+
ADNLPModels = "54578032-b7ea-4c30-94aa-7cbd1cce6c9a"
3+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
4+
OptimizationProblems = "5049e819-d29b-5fba-b941-0eee7e64c1c6"

benchmark/benchmarks.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using BenchmarkTools, ADNLPModels
2+
using OptimizationProblems
3+
using TimerNLPModels
4+
5+
# Run locally with `tune!(SUITE)` and then `run(SUITE)`
6+
const SUITE = BenchmarkGroup()
7+
8+
for n in [100, 1000]
9+
g = zeros(T, n)
10+
SUITE["grad! ref"]["$n"] = @benchmarkable grad!(nlp, get_x0(nlp), $g) setup = (nlp = OptimizationProblems.ADNLPProblems.arglina(n = $n), timed_nlp = TimerNLPModel(nlp))
11+
SUITE["grad! tim"]["$n"] = @benchmarkable grad!(timed_nlp, get_x0(nlp), $g) setup = (nlp = OptimizationProblems.ADNLPProblems.arglina(n = $n), timed_nlp = TimerNLPModel(nlp))
12+
end
13+
for n in [100, 1000]
14+
Hv = zeros(T, n)
15+
SUITE["hprod!"]["$n"] = @benchmarkable hprod!(nlp, get_x0(nlp), get_x0(nlp), $Hv) setup = (nlp = OptimizationProblems.ADNLPProblems.arglina(n = $n))
16+
end

0 commit comments

Comments
 (0)