-
Notifications
You must be signed in to change notification settings - Fork 0
/
timings.jl
57 lines (50 loc) · 1.65 KB
/
timings.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
import JSON
using Printf:@sprintf
using Base.Iterators:flatten
using Plots: plot, plot!, pyplot, theme
pyplot()
theme(:dark)
segments(timings) = [
[
(parse(Float64, t[1]), Float64(first(t[2]))),
(parse(Float64, t[1]), Float64(last(t[2]))),
(NaN, NaN)
] for t in filter(t -> length(t[2]) > 1, timings)
] |> flatten |> collect
function series(timings)
s = []
t = [[(parse(Float64, t[1]), Float64(r)) for r in t[2]] for t in timings]
while !isempty(filter!(!isempty, t))
push!(s, sort(popat!.(t, 1)))
end
s
end
function plots(jsons)
ylims = getindex.(jsons, "timings") .|>
flatten ∘ series |>
flatten |>
t -> (0.8 * minimum(last, t), 1.2 * maximum(last, t))
plots = []
for json in jsons
plot(json["timings"] |> segments, labels=:none, linestyle=:dot)
for (i, s) in json["timings"] |> series |> enumerate
plot!(s,
markershape=:circle,
title=json["title"],
legendtitle="completion refresh",
legend=:outerright,
labels=i |> i -> string(i, i < 4 ? ["st", "nd", "rd"][i] : "th", " refresh"),
link=:all,
xlabel="InsertCharPre",
ylabel="CompleteChanged",
yscale=:log10,
yticks=ylims[1]:0.1:ylims[2],
formatter=t -> @sprintf("%.1fs", t),
seriestype=i > 1 ? :scatter : :path)
end
push!(plots, plot!())
end
plots
end
timings(files) = plot(plots(JSON.parsefile.(files))..., layout=(length(files), 1)) |> display
timings(ARGS)