-
Notifications
You must be signed in to change notification settings - Fork 2
/
massage_benchmark_info_ibm.rb
129 lines (104 loc) · 3.39 KB
/
massage_benchmark_info_ibm.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
121
122
123
124
125
126
127
128
#!/usr/bin/env ruby
require 'fileutils'
require 'date'
dir_name = "/var/log/seph_benchmarks"
FileUtils.mkdir_p "build/performance_report"
def read_bench_file(f, names, collated_results)
raw_results = Hash.new do |h, k|
h[k] = []
end
open(f) do |f|
f.each_line do |line|
name, time_taken = line.chomp.split(/\|/)
raw_results[name] << Float(time_taken)
end
end
missing_names = names.dup
raw_results.each do |name, times|
missing_names.delete(name)
collated_results[name] << times.min
end
missing_names.each do |name|
collated_results[name] << nil
end
end
groups = {}
all_names = []
Dir["bench/bench_*.sp"].each do |f|
current_bench = []
open(f) do |of|
of.each_line do |l|
if l =~ /^benchmark\("(.*?)",/
current_bench << $1
end
end
all_names |= current_bench
groups[f] = current_bench.sort
end
end
collated_results = Hash.new do |h, k|
h[k] = []
end
entries = []
Dir["#{dir_name}/ibm_all_bench_results*"].sort.each do |f|
f =~ /ibm_all_bench_results-(.*?)$/
entries << $1
read_bench_file(f, all_names, collated_results)
end
index = 0
git_info = entries.map do |rev|
who, _when, what = `git show -s --format=format:"%ae|%ad|%s" #{rev}`.split(/\|/)
res = [rev, who, _when, DateTime.parse(_when), what, index]
index += 1
res
end.sort_by do |v|
v[3]
end
group_index = 0
groups.keys.sort.each do |group|
unless groups[group].empty?
out_file = File.basename(group, ".sp")
File.open("build/performance_report/#{out_file}_data.xml", "w") do |data_file|
data_file.puts "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
data_file.puts "<chart>"
data_file.puts " <series>"
git_info.each_with_index do |gi, ix|
data_file.puts " <value xid=\"#{ix}\">#{gi[0]}</value>"
end
data_file.puts " </series>"
data_file.puts " <graphs>"
gid = 0
groups[group].sort.each do |bname|
unless collated_results[bname].compact.empty?
data_file.puts " <graph gid=\"#{gid+1}\" title=\"#{bname.gsub("&", "&amp;").gsub(">", "&gt;").gsub("<", "&lt;")}\" balloon_text=\"{value} sec\">"
git_info.each_with_index do |gi, ix|
val = collated_results[bname][gi[5]]
data_file.puts " <value xid=\"#{ix}\" description=\" seconds\" url=\"https://github.com/seph-lang/seph/commit/#{gi[0]}\">#{val}</value>" if val
end
data_file.puts " </graph>"
gid += 1
end
end
data_file.puts " <graph gid=\"1\" title=\"revision\" hidden=\"true\" visible_in_legend=\"true\" color=\"#FFFFFF\" color_hover=\"#FFFFFF\" selected=\"false\">"
git_info.each_with_index do |gi, ix|
data_file.puts " <value xid=\"#{ix}\" description=\"#{gi[0]} &nbsp;- &nbsp;#{gi[1]}<br>#{gi[2]}<br>(click on chart for the changeset)<br><br>#{gi[4]}\" url=\"https://github.com/seph-lang/seph/commit/#{gi[0]}\">0</value>"
end
data_file.puts " </graph>"
data_file.puts " </graphs>"
data_file.puts <<LABEL
<labels>
<label lid="0">
<y>40</y>
<width>640</width>
<text_size>16</text_size>
<align>center</align>
<text>
<![CDATA[<b>Trunk - Best microbenchmark time - #{out_file}.sp</b>]]>
</text>
</label>
</labels>
</chart>
LABEL
end
end
end