-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.rb
120 lines (110 loc) · 3.55 KB
/
process.rb
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
require_relative "../file/data"
require_relative "build"
PERFORMANCE_SCALE = 1 << 20
PERFORMANCE_POSTFIX = "MB/s".freeze
CHART_DECLARATIONS = [
{
:name => "total ratio",
:value_keys => {
"ratio" => %i[total ratio]
}
},
{
:name => "total compress performance",
:scale => PERFORMANCE_SCALE,
:postfix => PERFORMANCE_POSTFIX,
:value_keys => {
"compress" => %i[total compress_performance]
}
},
{
:name => "total decompress performance",
:scale => PERFORMANCE_SCALE,
:postfix => PERFORMANCE_POSTFIX,
:value_keys => {
"decompress" => %i[total decompress_performance]
}
},
{
:name => "ratio limits",
:value_keys => {
"max" => %i[single ratio max],
"min" => %i[single ratio min]
}
},
{
:name => "compress performance limits",
:scale => PERFORMANCE_SCALE,
:postfix => PERFORMANCE_POSTFIX,
:value_keys => {
"max" => %i[single compress_performance max],
"min" => %i[single compress_performance min]
}
},
{
:name => "decompress performance limits",
:scale => PERFORMANCE_SCALE,
:postfix => PERFORMANCE_POSTFIX,
:value_keys => {
"max" => %i[single decompress_performance max],
"min" => %i[single decompress_performance min]
}
},
{
:name => "ratio",
:value_keys => {
"mode" => %i[single ratio mode],
"median" => %i[single ratio median],
"mean" => %i[single ratio mean],
"standard deviation" => %i[single ratio standard_deviation]
}
},
{
:name => "compress performance",
:scale => PERFORMANCE_SCALE,
:postfix => PERFORMANCE_POSTFIX,
:value_keys => {
"mode" => %i[single compress_performance mode],
"median" => %i[single compress_performance median],
"mean" => %i[single compress_performance mean],
"standard deviation" => %i[single compress_performance standard_deviation]
}
},
{
:name => "decompress performance",
:scale => PERFORMANCE_SCALE,
:postfix => PERFORMANCE_POSTFIX,
:value_keys => {
"mode" => %i[single decompress_performance mode],
"median" => %i[single decompress_performance median],
"mean" => %i[single decompress_performance mean],
"standard deviation" => %i[single decompress_performance standard_deviation]
}
}
]
.freeze
def process_charts(vendor, option_groups)
option_groups.each.with_index do |options, index|
extension = options[:extension]
type = options[:type]
data = load_files_data vendor, extension, type
if data.nil?
warn "data for vendor: #{vendor}, extension: #{extension}, type: #{type} is not found"
next
end
brotli_version = data[:brotli_version]
zstds_version = data[:zstds_version]
stats_datas = data[:stats_datas]
percent = format_percent index, option_groups.length
warn "- #{percent}% processing charts, vendor: #{vendor}, extension: #{extension}, type: #{type}"
CHART_DECLARATIONS.each.with_index do |declaration, declaration_index|
name = declaration[:name]
declaration_percent = format_percent declaration_index, CHART_DECLARATIONS.length
warn "#{declaration_percent}% processing chart, name: #{name}"
stats_datas.each do |stats_data|
build_chart vendor, extension, type, brotli_version, zstds_version, stats_data, declaration
end
end
end
nil
end