From c140e7701131f25f0580cd4a27d0f81fde10291c Mon Sep 17 00:00:00 2001 From: janbruedigam Date: Tue, 2 Jun 2020 16:11:07 +0200 Subject: [PATCH 01/17] Add simple test. --- benchmark/benchmarks.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index f4e44152..f40f8fb1 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -1,4 +1,5 @@ using BenchmarkTools SUITE = BenchmarkGroup() -SUITE["sum"] = @benchmarkable sum($(randn(10_000))) \ No newline at end of file +SUITE["sum"] = @benchmarkable sum($(randn(10_000))) +SUITE["sum2"] = @benchmarkable sum($(randn(10_000))) \ No newline at end of file From fe2d4e4e03b7ac05abb28af27c735a6c474a1721 Mon Sep 17 00:00:00 2001 From: janbruedigam Date: Tue, 2 Jun 2020 16:25:32 +0200 Subject: [PATCH 02/17] Benchmark real example. --- benchmark/benchmarks.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index f40f8fb1..687c661a 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -2,4 +2,9 @@ using BenchmarkTools SUITE = BenchmarkGroup() SUITE["sum"] = @benchmarkable sum($(randn(10_000))) -SUITE["sum2"] = @benchmarkable sum($(randn(10_000))) \ No newline at end of file +SUITE["sum2"] = @benchmarkable sum($(randn(10_000))) + +include("examples/atlas.jl") +steps = Base.OneTo(1000) +storage = Storage{Float64}(steps,length(mech.bodies)) +SUITE["atlastest"] = @benchmarkable simulate!($mech, $steps, $storage) samples=1 \ No newline at end of file From cc81ee01bd7c4dbb8a35527d6c85b3dcd69a95dd Mon Sep 17 00:00:00 2001 From: janbruedigam Date: Tue, 2 Jun 2020 16:32:53 +0200 Subject: [PATCH 03/17] Update path to benchmark examples. --- benchmark/benchmarks.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index 687c661a..08c6e9d8 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -4,7 +4,7 @@ SUITE = BenchmarkGroup() SUITE["sum"] = @benchmarkable sum($(randn(10_000))) SUITE["sum2"] = @benchmarkable sum($(randn(10_000))) -include("examples/atlas.jl") +include("../examples/atlas.jl") steps = Base.OneTo(1000) storage = Storage{Float64}(steps,length(mech.bodies)) SUITE["atlastest"] = @benchmarkable simulate!($mech, $steps, $storage) samples=1 \ No newline at end of file From 06014737ee5e33b3321c4061c381849c21cb6864 Mon Sep 17 00:00:00 2001 From: janbruedigam Date: Tue, 2 Jun 2020 16:51:39 +0200 Subject: [PATCH 04/17] Adjust MeshIO version for mesh displaying. --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 252fe863..b9b4ae5e 100644 --- a/Project.toml +++ b/Project.toml @@ -25,7 +25,7 @@ FileIO = "1.3.0" GeometryTypes = "0.7.10" LightXML = "0.9.0" MeshCat = "0.9.1" -MeshIO = "0.4.0" +MeshIO = "0.3.2" Plots = "1.0.14" Rotations = "0.13.0" StaticArrays = "0.12.3" From 3dd29e84dece0129500e42094491cdc2be4ce2fd Mon Sep 17 00:00:00 2001 From: janbruedigam Date: Tue, 2 Jun 2020 16:53:06 +0200 Subject: [PATCH 05/17] Use test files for benchmark. --- benchmark/benchmarks.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index 08c6e9d8..7ba3de64 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -4,7 +4,7 @@ SUITE = BenchmarkGroup() SUITE["sum"] = @benchmarkable sum($(randn(10_000))) SUITE["sum2"] = @benchmarkable sum($(randn(10_000))) -include("../examples/atlas.jl") +include("../test/examples/atlas.jl") steps = Base.OneTo(1000) storage = Storage{Float64}(steps,length(mech.bodies)) SUITE["atlastest"] = @benchmarkable simulate!($mech, $steps, $storage) samples=1 \ No newline at end of file From e7e3d32306c8648b97482a27a2e31b145412b628 Mon Sep 17 00:00:00 2001 From: janbruedigam Date: Tue, 2 Jun 2020 17:39:59 +0200 Subject: [PATCH 06/17] Move allocation tests to benchmark tests. --- benchmark/benchmarks.jl | 42 ++++++++++++++++++--- test/allocation_test.jl | 83 ----------------------------------------- test/runtests.jl | 4 -- 3 files changed, 36 insertions(+), 93 deletions(-) delete mode 100644 test/allocation_test.jl diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index 7ba3de64..7f407388 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -1,10 +1,40 @@ using BenchmarkTools SUITE = BenchmarkGroup() -SUITE["sum"] = @benchmarkable sum($(randn(10_000))) -SUITE["sum2"] = @benchmarkable sum($(randn(10_000))) -include("../test/examples/atlas.jl") -steps = Base.OneTo(1000) -storage = Storage{Float64}(steps,length(mech.bodies)) -SUITE["atlastest"] = @benchmarkable simulate!($mech, $steps, $storage) samples=1 \ No newline at end of file +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") + steps = Base.OneTo(1000) + storage = Storage{Float64}(steps,length(mech.bodies)) + if files[i]=="joint_force" || files[i]=="pendulum_forced" || files[i]=="football" || files[i]=="nutation" + SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $control!) samples=1 + else + SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage) samples=1 + end +end diff --git a/test/allocation_test.jl b/test/allocation_test.jl deleted file mode 100644 index ad10d4aa..00000000 --- a/test/allocation_test.jl +++ /dev/null @@ -1,83 +0,0 @@ -using BenchmarkTools - -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" -] - -warningtimes = [ - 1000.0 # 562.9592 - 50.0 # 24.4849 - 500.0 # 275.3259 - 4000.0 # 873.5784 - 5000.0 # 1249.2964 - 4000.0 # 900.5005 - 50.0 # 18.3757 - 100.0 # 30.044299 - 100.0 # 37.420599 - 4000.0 # 1688.237801 - 500.0 # 227.109 - 100.0 # 32.286301 - 100.0 # 26.4995 - 4000.0 # 2069.365999 - 1000.0 # 519.0557 - 25.0 # 4.226299 - 25.0 # 11.376999 - 25.0 # 11.785099 - 100.0 # 45.874299 - 100.0 # 42.6032 - 100.0 # 59.4295 - 500.0 # 173.376601 - 10.0 # 0.0 -]*10 - -time = zeros(length(files)) - -c1 = maximum(length.(files))+2 -c2 = 9 - -for i=1:length(files)-1 - include("examples/"*files[i]*".jl") - steps = Base.OneTo(1000) - storage = Storage{Float64}(steps,length(mech.bodies)) - if false - # elseif files[i]=="joint_force" || files[i]=="pendulum_forced" || files[i]=="football" || files[i]=="nutation" - # TODO once zero alloc works - # t = @benchmarkable simulate!($mech, $steps, $storage, $control!) - else - t = @benchmarkable simulate!($mech, $steps, $storage) - end - r = BenchmarkTools.minimum(run(t, samples=1)) - @test r.memory == 0 - time[i] = r.time/1e6 - @test time[i] < warningtimes[i] -end - -println(" "^(c1-7)*" Files | Time") -println("-"^(c1+c2+1)) -for i=1:length(files) - l = length(files[i]) - println((" "^(c1-l-1))*files[i]*" | "*string(time[i])) -end - diff --git a/test/runtests.jl b/test/runtests.jl index 4a3bc78a..ff92c61a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -24,8 +24,4 @@ end @safetestset "Example Tests" begin include("example_test.jl") -end - -@safetestset "Allocation Tests" begin - include("allocation_test.jl") end \ No newline at end of file From e33d898b06752afe4afb326a7f4ae90b7725ce66 Mon Sep 17 00:00:00 2001 From: janbruedigam Date: Tue, 2 Jun 2020 17:54:17 +0200 Subject: [PATCH 07/17] Update benchmark dependencies. --- benchmark/Project.toml | 3 ++- test/example_test.jl | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/benchmark/Project.toml b/benchmark/Project.toml index 88c0dd90..9cf5ecdf 100644 --- a/benchmark/Project.toml +++ b/benchmark/Project.toml @@ -1,3 +1,4 @@ [deps] BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" -PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d" \ No newline at end of file +PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" \ No newline at end of file diff --git a/test/example_test.jl b/test/example_test.jl index 53cd9945..a53a15e4 100644 --- a/test/example_test.jl +++ b/test/example_test.jl @@ -27,7 +27,7 @@ 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) From 6f4007efcabe550316b9790ee8ff55635cbc0401 Mon Sep 17 00:00:00 2001 From: janbruedigam Date: Tue, 2 Jun 2020 18:13:07 +0200 Subject: [PATCH 08/17] Try fix. --- .github/workflows/ci.yml | 4 +++- benchmark/benchmarks.jl | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb5a6fe2..2b320a74 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,10 +9,12 @@ 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' || matrix.version == '1.0' || matrix.version == '1.3'}} strategy: matrix: version: + - '1.0' + - '1.3' - '1.4' - 'nightly' os: diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index 7f407388..805ac1eb 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -33,7 +33,7 @@ for i=1:length(files)-1 steps = Base.OneTo(1000) storage = Storage{Float64}(steps,length(mech.bodies)) if files[i]=="joint_force" || files[i]=="pendulum_forced" || files[i]=="football" || files[i]=="nutation" - SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $control!) samples=1 + # SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $control!) samples=1 else SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage) samples=1 end From 41410e57d6bcdac5b96d804c1999f9f5dc4524f9 Mon Sep 17 00:00:00 2001 From: janbruedigam Date: Tue, 2 Jun 2020 18:31:45 +0200 Subject: [PATCH 09/17] Change benchmark evals. --- Project.toml | 2 +- benchmark/benchmarks.jl | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index b9b4ae5e..c78b4a2e 100644 --- a/Project.toml +++ b/Project.toml @@ -23,7 +23,7 @@ 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" diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index 805ac1eb..7381b1ec 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -30,11 +30,13 @@ files = [ for i=1:length(files)-1 include("../test/examples/"*files[i]*".jl") - steps = Base.OneTo(1000) + steps = Base.OneTo(100) storage = Storage{Float64}(steps,length(mech.bodies)) if files[i]=="joint_force" || files[i]=="pendulum_forced" || files[i]=="football" || files[i]=="nutation" # SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $control!) samples=1 + # elseif files[i]=="chain_in_chain" + # # else - SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage) samples=1 + SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage) samples=1 evals=1 end end From 4e984a51186cf48ac0fc34f2c0fba32a49bdbc8b Mon Sep 17 00:00:00 2001 From: janbruedigam Date: Tue, 2 Jun 2020 18:43:56 +0200 Subject: [PATCH 10/17] Exclude some benchmark examples. --- .github/workflows/ci.yml | 3 +-- Project.toml | 2 +- benchmark/benchmarks.jl | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b320a74..ebeb50c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,11 +9,10 @@ jobs: test: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.version == 'nightly' || matrix.version == '1.0' || matrix.version == '1.3'}} + continue-on-error: ${{ matrix.version == 'nightly'}} strategy: matrix: version: - - '1.0' - '1.3' - '1.4' - 'nightly' diff --git a/Project.toml b/Project.toml index c78b4a2e..f13916eb 100644 --- a/Project.toml +++ b/Project.toml @@ -29,7 +29,7 @@ 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" diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index 7381b1ec..fbf530e3 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -34,8 +34,8 @@ for i=1:length(files)-1 storage = Storage{Float64}(steps,length(mech.bodies)) if files[i]=="joint_force" || files[i]=="pendulum_forced" || files[i]=="football" || files[i]=="nutation" # SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $control!) samples=1 - # elseif files[i]=="chain_in_chain" - # # + elseif files[i]=="chain_in_chain" + # else SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage) samples=1 evals=1 end From c3bbec08be5bb3671c7f7dfa354b214f501598d6 Mon Sep 17 00:00:00 2001 From: janbruedigam Date: Tue, 2 Jun 2020 19:05:24 +0200 Subject: [PATCH 11/17] Rename benchmark control functions. --- benchmark/benchmarks.jl | 4 ++-- test/examples/football.jl | 2 +- test/examples/joint_force.jl | 2 +- test/examples/nutation.jl | 2 +- test/examples/pendulum_forced.jl | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index fbf530e3..150125ef 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -33,10 +33,10 @@ for i=1:length(files)-1 steps = Base.OneTo(100) storage = Storage{Float64}(steps,length(mech.bodies)) if files[i]=="joint_force" || files[i]=="pendulum_forced" || files[i]=="football" || files[i]=="nutation" - # SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $control!) samples=1 + SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $(eval(Meta.parse(files[i]*"_control!")))) samples=1 elseif files[i]=="chain_in_chain" # else - SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage) samples=1 evals=1 + SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage) samples=1 end end diff --git a/test/examples/football.jl b/test/examples/football.jl index 1497b4a3..7c7cf7fc 100644 --- a/test/examples/football.jl +++ b/test/examples/football.jl @@ -46,7 +46,7 @@ setPosition!(link4,link5,Δx = [0.;0.;0.03]) spin = 0.35 -function control!(mechanism, k) +function fottball_control!(mechanism, k) if k<25 setForce!(link3, F = SA[0.;25.;25.], τ=spin*SA[0.2;0.2;1.]) elseif k==40 diff --git a/test/examples/joint_force.jl b/test/examples/joint_force.jl index 9a5c2f87..543fb7f7 100644 --- a/test/examples/joint_force.jl +++ b/test/examples/joint_force.jl @@ -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 diff --git a/test/examples/nutation.jl b/test/examples/nutation.jl index a3048edb..d089ee8a 100644 --- a/test/examples/nutation.jl +++ b/test/examples/nutation.jl @@ -26,7 +26,7 @@ axis = [0;0;1.] speed = 20pi #*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]) else diff --git a/test/examples/pendulum_forced.jl b/test/examples/pendulum_forced.jl index d328a4b9..33d5c25d 100644 --- a/test/examples/pendulum_forced.jl +++ b/test/examples/pendulum_forced.jl @@ -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 From 0f46785bc74f8ccac310ac3a62a5d8ccd12759e4 Mon Sep 17 00:00:00 2001 From: janbruedigam Date: Tue, 2 Jun 2020 19:10:14 +0200 Subject: [PATCH 12/17] Different attempt at test control function names. --- benchmark/benchmarks.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index 150125ef..a20c9e3b 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -28,12 +28,15 @@ files = [ "wheel" ] +funcdict = Dict{Int64,Function}() + for i=1:length(files)-1 include("../test/examples/"*files[i]*".jl") steps = Base.OneTo(100) storage = Storage{Float64}(steps,length(mech.bodies)) if files[i]=="joint_force" || files[i]=="pendulum_forced" || files[i]=="football" || files[i]=="nutation" - SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $(eval(Meta.parse(files[i]*"_control!")))) samples=1 + funcdict[i] = eval(Meta.parse(files[i]*"_control!")) + SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $funcdict[i]) samples=1 elseif files[i]=="chain_in_chain" # else From d4ac0026d858135faaa2336d7341718f81ed80f8 Mon Sep 17 00:00:00 2001 From: janbruedigam Date: Tue, 2 Jun 2020 19:15:19 +0200 Subject: [PATCH 13/17] Update test. --- test/example_test.jl | 2 +- test/examples/football.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/example_test.jl b/test/example_test.jl index a53a15e4..a0389f48 100644 --- a/test/example_test.jl +++ b/test/example_test.jl @@ -30,7 +30,7 @@ for file in files # 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 diff --git a/test/examples/football.jl b/test/examples/football.jl index 7c7cf7fc..0dfc6d06 100644 --- a/test/examples/football.jl +++ b/test/examples/football.jl @@ -46,7 +46,7 @@ setPosition!(link4,link5,Δx = [0.;0.;0.03]) spin = 0.35 -function fottball_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 From 84e5f3863996c4de9eb68a4e9667179692e8746a Mon Sep 17 00:00:00 2001 From: janbruedigam Date: Tue, 2 Jun 2020 19:43:41 +0200 Subject: [PATCH 14/17] Update benchmark test for controlled examples. --- benchmark/benchmarks.jl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index a20c9e3b..a46d8725 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -34,9 +34,14 @@ for i=1:length(files)-1 include("../test/examples/"*files[i]*".jl") steps = Base.OneTo(100) storage = Storage{Float64}(steps,length(mech.bodies)) - if files[i]=="joint_force" || files[i]=="pendulum_forced" || files[i]=="football" || files[i]=="nutation" - funcdict[i] = eval(Meta.parse(files[i]*"_control!")) - SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $funcdict[i]) samples=1 + 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 From 1247a10b480ca10400726fb45269bd0d2e1b63ad Mon Sep 17 00:00:00 2001 From: janbruedigam Date: Tue, 2 Jun 2020 21:21:46 +0200 Subject: [PATCH 15/17] Focus benchmark more on size than problem. --- benchmark/benchmarks.jl | 47 +--------------------------------- benchmark/example_benchmark.jl | 47 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 46 deletions(-) create mode 100644 benchmark/example_benchmark.jl diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index a46d8725..3f4f6d27 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -2,49 +2,4 @@ using BenchmarkTools SUITE = BenchmarkGroup() -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" -] - -funcdict = Dict{Int64,Function}() - -for i=1:length(files)-1 - include("../test/examples/"*files[i]*".jl") - 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 +include("example_benchmark.jl") \ No newline at end of file diff --git a/benchmark/example_benchmark.jl b/benchmark/example_benchmark.jl new file mode 100644 index 00000000..30a86d30 --- /dev/null +++ b/benchmark/example_benchmark.jl @@ -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 From 0c213590e4135b114842510d9309aa88417f989c Mon Sep 17 00:00:00 2001 From: janbruedigam Date: Tue, 2 Jun 2020 21:33:39 +0200 Subject: [PATCH 16/17] Update nutation benchmark. --- test/examples/nutation.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/examples/nutation.jl b/test/examples/nutation.jl index d089ee8a..345f0f6d 100644 --- a/test/examples/nutation.jl +++ b/test/examples/nutation.jl @@ -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 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 From 90201b47e1ed8ff503bc76aafab2b2af1b73c1bb Mon Sep 17 00:00:00 2001 From: janbruedigam Date: Tue, 2 Jun 2020 21:45:13 +0200 Subject: [PATCH 17/17] Benchmark uncontrolled nutation. --- benchmark/example_benchmark.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/example_benchmark.jl b/benchmark/example_benchmark.jl index 30a86d30..737fe939 100644 --- a/benchmark/example_benchmark.jl +++ b/benchmark/example_benchmark.jl @@ -37,8 +37,8 @@ for i=1:length(files)-1 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]=="nutation" + # SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $nutation_control!) samples=1 # elseif files[i]=="chain_in_chain" # # else