Skip to content

Commit

Permalink
Add simple benchmark and benchmark workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
abelsiqueira authored and tmigot committed Sep 28, 2023
1 parent 4746031 commit 653202a
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
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 [email protected]"'
- 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 }}
4 changes: 4 additions & 0 deletions benchmark/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[deps]
ADNLPModels = "54578032-b7ea-4c30-94aa-7cbd1cce6c9a"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
JSOSuite = "ed6ae0be-a024-11e9-2788-05dbf8cd15d9"
14 changes: 14 additions & 0 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using BenchmarkTools, ADNLPModels
using JSOSuite

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

SUITE["solvers"] = BenchmarkGroup(["solver"])

nlp = ADNLPModel(x -> (x[1] - 1)^2 + 4 * (x[2] - x[1]^2)^2, [-1.2; 1.0])
for solver in eachrow(JSOSuite.select_optimizers(nlp))
SUITE["solvers"][solver.name] = @benchmarkable begin
minimize($(solver.name), $nlp)
end
end

0 comments on commit 653202a

Please sign in to comment.