Skip to content

Commit fa73f34

Browse files
authored
Add timingtable.jl (#851)
Add `test/timingtable.jl` file to create a table of timings of fits of models from `test/modelcache.jl` (the `kb07` data set by default). This file is not included in the test suite because it takes a long time to run. It is a standalone timing.
1 parent bf0210b commit fa73f34

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

test/timingtable.jl

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using Chairmarks, PRIMA, TypedTables
1+
using Chain, Chairmarks, PRIMA, DataFrames
22
include(joinpath(@__DIR__, "modelcache.jl"))
33

4-
@isdefined(timingtable) || function timingtable(
4+
@isdefined(timingtable) || function timingtable(;
55
dsname::Symbol=:insteval,
66
optimizers::Vector{NTuple{2,Symbol}}=
77
[
@@ -10,24 +10,41 @@ include(joinpath(@__DIR__, "modelcache.jl"))
1010
(:prima, :newuoa),
1111
(:prima, :bobyqa),
1212
],
13-
seconds::Integer = 1;
13+
seconds::Integer = 1
1414
)
1515
rowtype = @NamedTuple{
16-
modnum::Int,
16+
modnum::Int8,
17+
ntheta::Int8,
18+
dof::Int8,
1719
bkend::Symbol,
18-
optmzr::Symbol,
20+
optimizer::Symbol,
1921
feval::Int,
20-
objtiv::Float64,
22+
objective::Float64,
2123
time::Float64,
2224
}
2325
val = rowtype[]
2426
mods = models(dsname)
2527

2628
for (j, m) in enumerate(mods)
29+
ntheta = length(m.parmap)
2730
for (bk, opt) in optimizers
2831
bmk = @b refit!(m; progress=false, backend=bk, optimizer=opt) seconds=seconds
29-
push!(val, rowtype((j, bk, opt, m.optsum.feval, m.optsum.fmin, bmk.time)))
32+
push!(val, rowtype((j, ntheta, dof(m), bk, opt, m.optsum.feval, m.optsum.fmin, bmk.time)))
3033
end
3134
end
32-
return Table(val)
35+
return @chain DataFrame(val) begin
36+
groupby(:modnum)
37+
combine(
38+
:ntheta,
39+
:dof,
40+
:bkend,
41+
:optimizer,
42+
:feval,
43+
:objective,
44+
:time,
45+
:objective => minimum => :min_obj,
46+
)
47+
transform!([:objective, :min_obj] => ((x, y) -> x - y) => :del_obj)
48+
end
3349
end
50+

0 commit comments

Comments
 (0)