Skip to content

Commit

Permalink
Add bench/runbenchmarks.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
dmbates committed Mar 10, 2024
1 parent cfd3023 commit 58fa323
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9"
Aqua = "0.8"
Arrow = "1, 2"
BSplineKit = "0.14, 0.15, 0.16, 0.17"
Chairmarks = "1"
DataAPI = "1"
DataFrames = "1"
Distributions = "0.21, 0.22, 0.23, 0.24, 0.25"
Expand Down Expand Up @@ -65,6 +66,7 @@ julia = "1.8"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Chairmarks = "0ca39b1e-fe0b-4e98-acfc-b1656634c4de"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Expand All @@ -73,4 +75,4 @@ Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "DataFrames", "ExplicitImports", "InteractiveUtils", "StableRNGs", "Suppressor", "Test"]
test = ["Aqua", "Chairmarks", "DataFrames", "ExplicitImports", "InteractiveUtils", "StableRNGs", "Suppressor", "Test"]
64 changes: 64 additions & 0 deletions bench/runbenchmarks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using Chairmarks, MixedModels, StatsModels, TypedTables
using MixedModels: dataset

@isdefined(contrasts) || const contrasts = Dict{Symbol, Any}()

contrasts[:F] = HelmertCoding() # mrk17_exp1
contrasts[:P] = HelmertCoding() # mrk17_exp1
contrasts[:Q] = HelmertCoding() # mrk17_exp1
contrasts[:lQ] = HelmertCoding() # mrk17_exp1
contrasts[:lT] = HelmertCoding() # mrk17_exp1
contrasts[:ch] = HelmertCoding() # contra
contrasts[:load] = HelmertCoding() # kb07
contrasts[:prec] = HelmertCoding() # kb07
contrasts[:service] = HelmertCoding() # insteval
contrasts[:spkr] = HelmertCoding() # kb07

tbl = Table(
dsnm = [
:dyestuff2, :dyestuff, :machines, :pastes, :pastes, :penicillin,
:sleepstudy, :sleepstudy, :sleepstudy, :sleepstudy, :kb07, :kb07,
:mrk17_exp1, :insteval, :insteval, :kb07, :mrk17_exp1, :d3, :ml1m,
],
secs = append!(
fill(0.1f0, 12),
[1.0f0],
fill(5.0f0, 3),
fill(25.0f0, 4)
),
frm = StatsModels.FormulaTerm[
@formula(yield ~ 1 + (1|batch)),
@formula(yield ~ 1 + (1|batch)),
@formula(score ~ 1 + (1 | Worker) + (1 | Machine)),
@formula(strength ~ 1 + (1 | batch & cask)),
@formula(strength ~ 1 + (1 | batch / cask)),
@formula(diameter ~ 1 + (1 | plate) + (1 | sample)),
@formula(reaction ~ 1 + days + (1 | subj)),
@formula(reaction ~ 1 + days + zerocorr(1 + days | subj)),
@formula(reaction ~ 1 + days + (1 | subj) + (0 + days | subj)),
@formula(reaction ~ 1 + days + (1 + days | subj)),
@formula(log(rt_trunc) ~ 1 + spkr + prec + load + (1 | subj) + (1 | item)),
@formula(log(rt_trunc) ~ 1 + spkr * prec * load + (1 | subj) + (1 + prec | item)),
@formula(1000 / rt ~ 1 + F * P * Q * lQ * lT + (1 | item) + (1 | subj)),
@formula(y ~ 1 + service * dept + (1 | s) + (1 | d)),
@formula(y ~ 1 + service + (1 | s) + (1 | d) + (1 | dept)),
@formula(
log(rt_trunc) ~
1 + spkr * prec * load + (1 + spkr + prec + load | subj) +
(1 + spkr + prec + load | item)
),
@formula(
1000 / rt ~
1 + F * P * Q * lQ * lT + (1 + P + Q + lQ + lT | item) +
(1 + F + P + Q + lQ + lT | subj)
),
@formula(y ~ 1 + u + (1 + u | g) + (1 + u | h) + (1 + u | i)),
@formula(y ~ 1 + (1 | g) + (1 | h)),
]
)

linmark(f, d, t) = @b fit(MixedModel, f, dataset(d); contrasts, progress=false) seconds=t

function runbmrk(tbl)
Table([(; bmk=linmark(f, d, t), dsnm = d, frm=f) for (d, t, f) in tbl])
end

0 comments on commit 58fa323

Please sign in to comment.