Skip to content

Commit

Permalink
Merge pull request #9 from janbruedigam/benchmarks
Browse files Browse the repository at this point in the history
Add benchmarks
  • Loading branch information
janbruedigam authored Jun 2, 2020
2 parents 3339f7f + 90201b4 commit 7d7b337
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 100 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.version == 'nightly' }}
continue-on-error: ${{ matrix.version == 'nightly'}}
strategy:
matrix:
version:
- '1.3'
- '1.4'
- 'nightly'
os:
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ Colors = "0.11.2"
CoordinateTransformations = "0.5.1"
FileIO = "1.3.0"
GeometryTypes = "0.7.10"
LightXML = "0.9.0"
LightXML = "0.8.1, 0.9.0"
MeshCat = "0.9.1"
MeshIO = "0.3.2"
Plots = "1.0.14"
Rotations = "0.13.0"
StaticArrays = "0.12.3"
julia = "1.4"
julia = "1.3, 1.4"

[extras]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Expand Down
3 changes: 2 additions & 1 deletion benchmark/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d"
PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
3 changes: 2 additions & 1 deletion benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BenchmarkTools

SUITE = BenchmarkGroup()
SUITE["sum"] = @benchmarkable sum($(randn(10_000)))

include("example_benchmark.jl")
47 changes: 47 additions & 0 deletions benchmark/example_benchmark.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
files = [
"atlas"
"axes"
"chain_in_chain"
"dice_nofriction"
"dice_tiltedplane"
"dice"
"disconnected_bodies"
"doublependulum_3d"
"doublependulum_urdf"
"football"
"inverted_pyramid_plane"
"joint_force"
"joint_torque"
"n_fourbars"
"n_pendulum"
"nutation"
"pendulum_forced"
"pendulum"
"planar_example"
"scissor_lift"
"slider_crank"
"slider_crank3d"
"wheel"
]

for i=1:length(files)-1
include("../test/examples/"*files[i]*".jl")
mech.g = 0.0

steps = Base.OneTo(100)
storage = Storage{Float64}(steps,length(mech.bodies))

if files[i]=="joint_force"
SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $joint_force_control!) samples=1
elseif files[i]=="pendulum_forced"
SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $pendulum_forced_control!) samples=1
elseif files[i]=="football"
SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $football_control!) samples=1
# elseif files[i]=="nutation"
# SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $nutation_control!) samples=1
# elseif files[i]=="chain_in_chain"
# #
else
SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage) samples=1
end
end
83 changes: 0 additions & 83 deletions test/allocation_test.jl

This file was deleted.

4 changes: 2 additions & 2 deletions test/example_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ files = [
]

for file in files
println(file)
# println(file)
include("examples/"*file*".jl")
if file=="joint_force" || file=="pendulum_forced" || file=="nutation" || file=="football"
storage = simulate!(mech, 10., control!, record = true)
storage = simulate!(mech, 10., eval(Meta.parse(file*"_control!")), record = true)
else
storage = simulate!(mech, 10., record = true)
end
Expand Down
2 changes: 1 addition & 1 deletion test/examples/football.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ setPosition!(link4,link5,Δx = [0.;0.;0.03])

spin = 0.35

function control!(mechanism, k)
function football_control!(mechanism, k)
if k<25
setForce!(link3, F = SA[0.;25.;25.], τ=spin*SA[0.2;0.2;1.])
elseif k==40
Expand Down
2 changes: 1 addition & 1 deletion test/examples/joint_force.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ links = [link1; link2]
constraints = [joint0to1;joint1to2]
shapes = [b1;b2]

function control!(mechanism, k)
function joint_force_control!(mechanism, k)
F = SVector{2,Float64}(0.1,0.)
setForce!(mechanism, joint1to2, F)
return
Expand Down
6 changes: 3 additions & 3 deletions test/examples/nutation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ shapes = [b1]
mech = Mechanism(origin, links, constraints, g = 0., shapes = shapes)

axis = [0;0;1.]
speed = 20pi #*0
speed = 2pi #*0
setVelocity!(link1, ω = speed*axis)

function control!(mechanism, k)
function nutation_control!(mechanism, k)
if k==1
setForce!(mechanism.bodies[1], F = SA[0;0;2.], p=SA[0;1.;0])
setForce!(mechanism.bodies[1], F = SA[0;0;0.2], p=SA[0;1.;0])
else
setForce!(mechanism.bodies[1], F = SA[0;0;0.], p=SA[0;0.0;0])
end
Expand Down
2 changes: 1 addition & 1 deletion test/examples/pendulum_forced.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mech = Mechanism(origin, links, constraints, shapes = shapes)
setPosition!(origin,link1,p2 = p2,Δq = q1)

jointid = constraints[1].id
function control!(mechanism, k)
function pendulum_forced_control!(mechanism, k)
τ = SVector{1,Float64}(cos(0.5 * k*0.01 * 2pi))
setForce!(mechanism, geteqconstraint(mechanism,jointid), τ)
end
4 changes: 0 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,4 @@ end

@safetestset "Example Tests" begin
include("example_test.jl")
end

@safetestset "Allocation Tests" begin
include("allocation_test.jl")
end

2 comments on commit 7d7b337

@janbruedigam
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/15768

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" 7d7b3376822bb76216586f4b1d57839610850b5b
git push origin v0.1.0

Please sign in to comment.