/
BenchPkgPlot.jl
66 lines (56 loc) · 1.89 KB
/
BenchPkgPlot.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
module BenchPkgPlot
using ..PlotUtils: combined_plots
using ..Utils: load_results
using PlotlyKaleido: savefig, start
using Comonicon
using Comonicon: @main
"""
benchpkgplot package_name [-r --rev <arg>] [-i --input-dir <arg>]
[-o --output-dir <arg>] [-n --npart <arg>]
[--format <arg>]
Plot the benchmarks of a package as created with `benchpkg`.
# Arguments
- `package_name`: Name of the package.
# Options
- `-r, --rev <arg>`: Revisions to test (delimit by comma).
- `-i, --input-dir <arg>`: Where the JSON results were saved (default: ".").
- `-o, --output-dir <arg>`: Where to save the plots results (default: ".").
- `-n, --npart <arg>`: Max number of plots per page (default: 10).
- `--format <arg>`: File type to save the plots as (default: "png").
"""
@main function benchpkgplot(
package_name::String;
rev::String,
input_dir::String=".",
output_dir::String=".",
npart::Int=10,
format::String="png",
)
revs = convert(Vector{String}, split(rev, ","))
# Filter empty strings:
revs = filter(x -> length(x) > 0, revs)
@assert length(revs) > 0 "No revisions specified."
combined_results = load_results(package_name, revs; input_dir=input_dir)
plots = combined_plots(combined_results; npart=npart)
@info "Saving plots."
start()
if length(plots) == 1
savefig(
first(plots),
joinpath(output_dir, "plot_$(package_name).$(format)");
height=first(plots).layout.height,
width=first(plots).layout.width,
)
else
for (i, p) in enumerate(plots)
savefig(
p,
joinpath(output_dir, "plot_$(package_name)_$i.$(format)");
height=p.layout.height,
width=p.layout.width,
)
end
end
return nothing
end
end # AirspeedVelocity.BenchPkgPlot