Skip to content

Commit 9f13560

Browse files
Merge pull request #22 from JuliaDiffEq/myb/timing
Use minimum for ODE timing and use the old timing scheme for RODE
2 parents 6d8c36a + d1f2d7d commit 9f13560

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed

src/benchmark.jl

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function ode_shootout(args...;kwargs...)
2828
ShootOut(args...;kwargs...)
2929
end
3030

31-
benchtime(bench) = BenchmarkTools.time(mean(bench))/1e9
31+
benchtime(bench) = BenchmarkTools.time(minimum(bench))/1e9
3232

3333
function Shootout(prob,setups;appxsol=nothing,names=nothing,error_estimate=:final,numruns=20,seconds=2,kwargs...)
3434
N = length(setups)
@@ -299,9 +299,9 @@ end
299299
end
300300

301301
function WorkPrecisionSet(prob::AbstractRODEProblem,abstols,reltols,setups,test_dt=nothing;
302-
numruns_error = 20,
302+
numruns=20,numruns_error = 20,
303303
print_names=false,names=nothing,appxsol_setup=nothing,
304-
error_estimate=:final,parallel_type = :none,numruns=20,seconds=Inf,kwargs...)
304+
error_estimate=:final,parallel_type = :none,kwargs...)
305305

306306
timeseries_errors = DiffEqBase.has_analytic(prob.f) && error_estimate TIMESERIES_ERRORS
307307
weak_timeseries_errors = error_estimate WEAK_TIMESERIES_ERRORS
@@ -313,6 +313,7 @@ function WorkPrecisionSet(prob::AbstractRODEProblem,abstols,reltols,setups,test_
313313
if names == nothing
314314
names = [string(parameterless_type(setups[i][:alg])) for i=1:length(setups)]
315315
end
316+
time_tmp = Vector{Float64}(undef,numruns)
316317

317318
# First calculate all of the errors
318319
if parallel_type == :threads
@@ -352,37 +353,28 @@ function WorkPrecisionSet(prob::AbstractRODEProblem,abstols,reltols,setups,test_
352353
dense_errors = dense_errors)
353354
end
354355
end
356+
GC.gc()
355357
# Now time it
356358
for k in 1:N
357359
for j in 1:M
358-
fails = 0
359-
local benchable
360-
@label START
361-
try
362-
benchable = if !haskey(setups[k],:dts)
363-
@benchmarkable(solve($prob,$(setups[k][:alg]);
364-
$kwargs...,
365-
abstol=$(abstols[j]),
366-
reltol=$(reltols[j]),
360+
for i in 1:numruns
361+
time_tmp[i] = @elapsed if !haskey(setups[k],:dts)
362+
sol = solve(prob,setups[k][:alg];
363+
kwargs...,
364+
abstol=abstols[j],
365+
reltol=reltols[j],
367366
timeseries_errors=false,
368-
dense_errors = false))
367+
dense_errors = false)
369368
else
370-
@benchmarkable(solve($prob,$(setups[k][:alg]);
371-
$kwargs...,abstol=$(abstols[j]),
372-
reltol=$(reltols[j]),dt=$(setups[k][:dts][j]),
373-
timeseries_errors=false,
374-
dense_errors = false))
369+
sol = solve(prob,setups[k][:alg];
370+
kwargs...,abstol=abstols[j],
371+
reltol=reltols[j],dt=setups[k][:dts][j],
372+
timeseries_errors=false,
373+
dense_errors = false)
375374
end
376-
catch
377-
# sometimes BenchmarkTools errors with
378-
# `ERROR: syntax: function argument and static parameter names must be distinct`
379-
# so, we are catching that error and try a few times.
380-
fails += 1
381-
fails > 4 && rethrow()
382-
@goto START
383375
end
384-
bench = run(benchable, samples=numruns, seconds=seconds)
385-
times[j,k] = benchtime(bench)
376+
times[j,k] = mean(time_tmp)
377+
GC.gc()
386378
end
387379
end
388380

0 commit comments

Comments
 (0)