-
Notifications
You must be signed in to change notification settings - Fork 0
/
survival-rate-profile-parser.jl
72 lines (67 loc) · 2.08 KB
/
survival-rate-profile-parser.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
67
68
69
70
71
72
const doc = """survival-rate-profile-parser.jl -- Parses a survival-rate profile JSON file
Usage:
survival-rate-profile-parser.jl [<name>]
survival-rate-profile-parser.jl -h | --help
survival-rate-profile-parser.jl --version
"""
using DocOpt
using JSON3
using Plots
using Printf
const args = docopt(doc, version = v"0.1.1")
const GC_N_MAX_POOLS = 51
const GC_MAX_DISPLAYED_AGE = 16
function main()
name = args["<name>"]
parse_survival_rate_profile(name)
end
function parse_survival_rate_profile(filename::String)
global GC_MAX_DISPLAYED_AGE
dict = JSON3.read(filename)
dict_mutable = copy(dict)
d = Dict{}()
# normalize the survival rate profile
for (k, v) in dict_mutable
tmp::Vector{Float64} = v
if v[1] != 0
tmp ./= v[1]
end
d[k] = tmp
end
# remove the previous fig directory
if isdir("fig")
rm("fig"; recursive = true)
end
# create a /fig directory
mkdir("fig")
for i = 0:GC_N_MAX_POOLS-1
# bar plot on light blue color without displaying
p1 = bar(
1:GC_MAX_DISPLAYED_AGE,
d[Symbol("pool_", i)][1:GC_MAX_DISPLAYED_AGE],
title = @sprintf("Survival Rate Profile of Normal Pool %03d", i),
xlabel = "Age",
ylabel = "Survival Rate",
label = "Normal Pools",
legend = true,
color = :lightblue,
show = false,
)
# now plot the one for i + GC_N_MAX_POOLS, but in light green
p2 = bar(
1:GC_MAX_DISPLAYED_AGE,
d[Symbol("pool_", i + GC_N_MAX_POOLS)][1:GC_MAX_DISPLAYED_AGE],
title = @sprintf("Survival Rate Profile of Compiler Pool %03d", i),
xlabel = "Age",
ylabel = "Survival Rate",
label = "Compiler Pools",
legend = true,
color = :lightgreen,
show = false,
)
# save the plot to a file
p = plot(p1, p2, layout = (2, 1), size = (800, 600))
savefig(p, @sprintf("fig/survival_rate_profile_%03d.png", i))
end
end
main()