Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/Benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Run benchmarks

on:
pull_request:
paths:
- "src/**"
- "benchmark/**"
- "Project.toml"
- "benchmark/Project.toml"

permissions:
contents: write
issues: write
pull-requests: 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@latest
with:
version: 1
- uses: julia-actions/julia-buildpkg@latest
- name: Install dependencies
run: julia -e 'using Pkg; pkg"add PkgBenchmark BenchmarkCI@0.1"'
- name: Run benchmarks
run: julia -e 'using BenchmarkCI; BenchmarkCI.judge(baseline="origin/main")'
- name: Post results
run: julia -e 'using BenchmarkCI; BenchmarkCI.postjudge()'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 5 additions & 0 deletions benchmark/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[deps]
ADNLPModels = "54578032-b7ea-4c30-94aa-7cbd1cce6c9a"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
NLPModels = "a4795742-8479-5a88-8948-cc11e1c8c1a6"
OptimizationProblems = "5049e819-d29b-5fba-b941-0eee7e64c1c6"
22 changes: 22 additions & 0 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using BenchmarkTools, ADNLPModels, NLPModels
using OptimizationProblems
using TimerNLPModels

# Run locally with `tune!(SUITE)` and then `run(SUITE)`
const SUITE = BenchmarkGroup()

for n in [100, 1000]
g = zeros(n)
SUITE["grad! ref"]["$n"] = @benchmarkable grad!(nlp, get_x0(nlp), $g) setup =
(nlp = OptimizationProblems.ADNLPProblems.arglina(n = $n))
SUITE["grad! tim"]["$n"] = @benchmarkable grad!(timed_nlp, get_x0(timed_nlp), $g) setup =
(timed_nlp = TimerNLPModel(OptimizationProblems.ADNLPProblems.arglina(n = $n)))
end
for n in [100, 1000]
Hv = zeros(n)
SUITE["hprod! ref"]["$n"] = @benchmarkable hprod!(nlp, get_x0(nlp), get_x0(nlp), $Hv) setup =
(nlp = OptimizationProblems.ADNLPProblems.arglina(n = $n))
SUITE["hprod! tim"]["$n"] =
@benchmarkable hprod!(timed_nlp, get_x0(timed_nlp), get_x0(timed_nlp), $Hv) setup =
(timed_nlp = TimerNLPModel(OptimizationProblems.ADNLPProblems.arglina(n = $n)))
end
Loading