Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup benchmarking #15

Merged
merged 6 commits into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 20 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Run benchmarks

on:
pull_request:

jobs:
Benchmark:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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(retune=true)' # retune sometimes necessary to avoid counting compile-time
- name: Print judgement
run: julia -e 'using BenchmarkCI; BenchmarkCI.displayjudgement()'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Files from local benchmarking
benchmark/tune.json

# Files generated by invoking Julia with --code-coverage
*.jl.cov
*.jl.*.cov
Expand Down
3 changes: 3 additions & 0 deletions benchmark/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
janbruedigam marked this conversation as resolved.
Show resolved Hide resolved
PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d"
5 changes: 5 additions & 0 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using BenchmarkTools

SUITE = BenchmarkGroup()

include("example_benchmark.jl")
49 changes: 49 additions & 0 deletions benchmark/example_benchmark.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
###############################
### Example benchmark for Atlas
###############################
mech = get_mechanism(:atlas,
timestep=0.1,
gravity=-9.81,
friction_coefficient=0.5,
damper=25.0,
spring=1.0,
contact_feet=true,
contact_body=true,
model_type=:simple)

Dojo.initialize!(mech, :atlas_stance,
body_position=[0.0, 0.0, 1.0],
body_orientation=[0.0, 0.2, 0.1])

SUITE["atlas"] = @benchmarkable simulate!($mech, 2.5, opts=SolverOptions(rtol=1.0e-6, btol=1.0e-6)) samples=2


###############################
### Example benchmark for Pendulum
###############################
mechanism = get_mechanism(:pendulum,
timestep=0.01,
gravity=-9.81,
damper=5.0,
spring=0.0)

function controller!(mechanism, t)
## Target state
x_goal = [1.0 * π; 0.0]

## Current state
x = get_minimal_state(mechanism)

## Gains
K = [5.0 0.5] * 0.1

# Control inputs
u = -K * (x - x_goal)
set_input!(mechanism, u)
end

initialize!(mechanism, :pendulum,
angle=0.0 * π,
angular_velocity=0.0);

SUITE["pendulum"] = @benchmarkable simulate!($mechanism, 2.0, $controller!) samples=2