|
using BenchmarkTools |
|
using DataFrames |
|
using Glob |
|
using PkgBenchmark |
|
using VegaLite |
|
using FileIO |
|
|
|
function readsweep(resultdir) |
|
results = map(PkgBenchmark.readresults, sort!(readdir(glob"result-*.json", resultdir))) |
|
table = |
|
Iterators.map(results) do r |
|
nthreads = parse(Int, r.benchmarkconfig.env["JULIA_NUM_THREADS"]) |
|
Iterators.map(leaves(r.benchmarkgroup)) do ((prob,), trial) |
|
@assert startswith(prob, "n=") |
|
n = parse(Int, prob[length("n=")+1:end]) |
|
(; nthreads, n, trial) |
|
end |
|
end |> |
|
Iterators.flatten |> |
|
collect |
|
|
|
df = DataFrame(table) |
|
df[!, :time] = map(trial -> minimum(trial).time, df.trial) |
|
return df |
|
end |
|
|
|
df_baseline = readsweep(joinpath(@__DIR__, "build/baseline/bench_mat_vec_mul")) |
|
df_target = readsweep(joinpath(@__DIR__, "build/target/bench_mat_vec_mul")) |
|
|
|
df_raw = leftjoin( |
|
df_baseline, |
|
df_target; |
|
on = [:nthreads, :n], |
|
renamecols = "_baseline" => "_target", |
|
) |
|
df_raw[!, :speedup] = df_raw.time_baseline ./ df_raw.time_target |
|
df_raw |
|
#- |
|
|
|
plt_speedup = @vlplot( |
|
data = select(df_raw, Not([:trial_baseline, :trial_target])), # avoid serializing trials |
|
layer = [ |
|
{ |
|
mark = {type = :line, point = true}, |
|
encoding = { |
|
x = {field = :nthreads}, |
|
y = {field = :speedup, title = "Seedup (target vs baseline)"}, |
|
color = {field = :n, type = :ordinal, title = "size(A, 1)"}, |
|
}, |
|
}, |
|
{ |
|
mark = {type = :rule}, |
|
encoding = { |
|
y = {datum = 1}, |
|
}, |
|
}, |
|
], |
|
) |
|
save(joinpath(@__DIR__, "build", "speedup.png"), plt_speedup) |
|
plt_speedup |
|
#- |
|
|
|
function speedup_wrt_singlethread(df, label) |
|
df = select(df, Not(:trial)) |
|
df[!, :version] .= label |
|
return combine(groupby(df, [:n, :version])) do g |
|
t1 = only(g[g.nthreads.==1, :]).time |
|
(; g.nthreads, speedup = t1 ./ g.time) |
|
end |
|
end |
|
|
|
df_scaling = vcat( |
|
speedup_wrt_singlethread(df_baseline, :baseline), |
|
speedup_wrt_singlethread(df_target, :target), |
|
) |
|
|
|
plt_scaling = @vlplot( |
|
mark = {type = :line, point = true}, |
|
x = :nthreads, |
|
y = {:speedup, title = "Seedup (vs nthreads=1)"}, |
|
column = {:n, type = :ordinal, title = "size(A, 1)"}, |
|
color = :version, |
|
data = df_scaling, |
|
) |
|
save(joinpath(@__DIR__, "build", "scaling.png"), plt_scaling) |
|
plt_scaling |
|
#- |