Skip to content

Commit 80fa4ac

Browse files
authored
Merge pull request #15 from dojo-sim/benchmark_example
Setup benchmarking
2 parents e96c658 + e5f008f commit 80fa4ac

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed

.github/workflows/benchmark.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Run benchmarks
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
Benchmark:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: julia-actions/setup-julia@latest
12+
with:
13+
version: 1
14+
# - uses: julia-actions/julia-buildpkg@latest
15+
- name: Install dependencies
16+
run: julia -e 'using Pkg; pkg"add PkgBenchmark BenchmarkCI@0.1"'
17+
- name: Run benchmarks
18+
run: julia -e 'using BenchmarkCI; BenchmarkCI.judge(retune=true,baseline="origin/main")' # retune sometimes necessary to avoid counting compile-time
19+
- name: Print judgement
20+
run: julia -e 'using BenchmarkCI; BenchmarkCI.displayjudgement()'

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Files from local benchmarking
2+
benchmark/tune.json
3+
14
# Files generated by invoking Julia with --code-coverage
25
*.jl.cov
36
*.jl.*.cov

benchmark/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[deps]
2+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
3+
PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d"

benchmark/benchmarks.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using BenchmarkTools
2+
3+
SUITE = BenchmarkGroup()
4+
5+
include("example_benchmark.jl")

benchmark/example_benchmark.jl

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using Dojo
2+
3+
###############################
4+
### Example benchmark for Atlas
5+
###############################
6+
mech = get_mechanism(:atlas,
7+
timestep=0.1,
8+
gravity=-9.81,
9+
friction_coefficient=0.5,
10+
damper=25.0,
11+
spring=1.0,
12+
contact_feet=true,
13+
contact_body=true,
14+
model_type=:simple)
15+
16+
Dojo.initialize!(mech, :atlas_stance,
17+
body_position=[0.0, 0.0, 1.0],
18+
body_orientation=[0.0, 0.2, 0.1])
19+
20+
SUITE["atlas"] = @benchmarkable simulate!($mech, 2.5, opts=SolverOptions(rtol=1.0e-6, btol=1.0e-6)) samples=2
21+
22+
23+
###############################
24+
### Example benchmark for Pendulum
25+
###############################
26+
mechanism = get_mechanism(:pendulum,
27+
timestep=0.01,
28+
gravity=-9.81,
29+
damper=5.0,
30+
spring=0.0)
31+
32+
function controller!(mechanism, t)
33+
## Target state
34+
x_goal = [1.0 * π; 0.0]
35+
36+
## Current state
37+
x = get_minimal_state(mechanism)
38+
39+
## Gains
40+
K = [5.0 0.5] * 0.1
41+
42+
# Control inputs
43+
u = -K * (x - x_goal)
44+
set_input!(mechanism, u)
45+
end
46+
47+
initialize!(mechanism, :pendulum,
48+
angle=0.0 * π,
49+
angular_velocity=0.0);
50+
51+
SUITE["pendulum"] = @benchmarkable simulate!($mechanism, 2.0, $controller!) samples=2

0 commit comments

Comments
 (0)