1+ using BenchmarkTools
2+ using CairoMakie
3+ using DataFrames
4+
5+ include (" benchmarks.jl" )
6+
7+ results = run (SUITE ; verbose = true )
8+
9+ df = DataFrame (; constructor = String[], suite = String[], f = String[], trial = BenchmarkTools. Trial[])
10+
11+ for (name, T) in interval_constructors
12+ # for suite in suites
13+ begin
14+ suite = " basics"
15+ suite_df = DataFrame (results[name][suite], [:f , :trial ])
16+ suite_df[:, :constructor ] .= name
17+ suite_df[:, :suite ] .= suite
18+ df = vcat (df, suite_df)
19+ end
20+ end
21+
22+ transform! (df,
23+ :trial => ByRow (trial -> minimum (trial. times)) => :minimum ,
24+ :trial => ByRow (trial -> mean (trial. times)) => :mean ,
25+ :trial => ByRow (trial -> median (trial. times)) => :median
26+ )
27+
28+ df[:, :relative ] .= 0.0
29+
30+ for group in groupby (df, :f )
31+ group[:, :relative ] .= group[:, :median ] ./ only (group[group. constructor .== " bareinterval" , :median ])
32+ end
33+
34+ begin
35+ fig = Figure (size = (800 , 500 ))
36+
37+ data = df[df. suite .== " basics" , :]
38+
39+ fs = vcat (string .(basic_arithmetic), string .(basic_functions))
40+ to_x = Dict (f => k for (k, f) in enumerate (fs))
41+ xx = [to_x[f] for f in data. f]
42+
43+ constructors = [" bareinterval" , " interval" , " BigFloat bareinterval" , " BigFloat interval" , " BigFloat MPFI" ]
44+ to_dodge = Dict (constructor => k for (k, constructor) in enumerate (constructors))
45+ dodge = [to_dodge[constructor] for constructor in data. constructor]
46+
47+ ax = Axis (fig[1 , 1 ] ;
48+ xlabel = " Benchmarked function" ,
49+ xticks = (1 : length (fs), fs),
50+ ylabel = " Relative execution time (log scale)" ,
51+ yscale = log10,
52+ )
53+
54+ barplot! (ax, xx, data. relative ;
55+ dodge,
56+ color = dodge,
57+ colormap = :mpetroff_10 ,
58+ colorrange = (1 , 10 ),
59+ )
60+
61+ Legend (fig[0 , 1 ],
62+ [LineElement (linewidth = 20 , color = to_colormap (:mpetroff_10 )[k]) for k in eachindex (constructors)],
63+ constructors ;
64+ tellwidth = false ,
65+ orientation = :horizontal
66+ )
67+
68+ fig
69+ end
0 commit comments