Skip to content

Commit 5275ee6

Browse files
committed
add benchmarking utility
1 parent 93c9c7d commit 5275ee6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/Multibody.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ function find_arry_problems(model)
2828
end
2929
end
3030

31+
"""
32+
benchmark_f(prob)
33+
34+
Benchmark the invocation of the function `prob.f` on the initial condition `prob.u0`
35+
"""
36+
function benchmark_f(prob)
37+
x = prob.u0
38+
dx = similar(x)
39+
p = prob.p
40+
if !isdefined(Main, :btime)
41+
@eval Main using BenchmarkTools
42+
end
43+
Main.@btime $(prob.f)($dx, $x, $p, 0.0)
44+
end
45+
3146
"""
3247
scene, time = render(model, sol, t::Real; framerate = 30, traces = [])
3348
path = render(model, sol, timevec = range(sol.t[1], sol.t[end], step = 1 / framerate); framerate = 30, timescale=1, display=false, loop=1)

0 commit comments

Comments
 (0)