Skip to content

Commit 145f8ec

Browse files
committed
Extract methods to explain what the data means
1 parent 74b7d89 commit 145f8ec

1 file changed

Lines changed: 31 additions & 12 deletions

File tree

lib/results_table_builder.rb

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,46 +29,46 @@ def build
2929

3030
def build_header
3131
header = ["bench"]
32-
32+
3333
@executable_names.each do |name|
3434
header += ["#{name} (ms)", "stddev (%)"]
3535
header += ["RSS (MiB)"] if @include_rss
3636
end
37-
37+
3838
@other_names.each do |name|
3939
header += ["#{name} 1st itr"]
4040
end
41-
41+
4242
@other_names.each do |name|
4343
header += ["#{@base_name}/#{name}"]
4444
end
45-
45+
4646
header
4747
end
4848

4949
def build_format
5050
format = ["%s"]
51-
51+
5252
@executable_names.each do |_name|
5353
format += ["%.1f", "%.1f"]
5454
format += ["%.1f"] if @include_rss
5555
end
56-
56+
5757
@other_names.each do |_name|
5858
format += ["%.3f"]
5959
end
60-
60+
6161
@other_names.each do |_name|
6262
format += ["%.3f"]
6363
end
64-
64+
6565
format
6666
end
6767

6868
def build_row(bench_name)
69-
t0s = @executable_names.map { |name| (bench_data_for(name, bench_name)['warmup'][0] || bench_data_for(name, bench_name)['bench'][0]) * 1000.0 }
70-
times_no_warmup = @executable_names.map { |name| bench_data_for(name, bench_name)['bench'].map { |v| v * 1000.0 } }
71-
rsss = @executable_names.map { |name| bench_data_for(name, bench_name)['rss'] / 1024.0 / 1024.0 }
69+
t0s = extract_first_iteration_times(bench_name)
70+
times_no_warmup = extract_benchmark_times(bench_name)
71+
rsss = extract_rss_values(bench_name)
7272

7373
base_t0, *other_t0s = t0s
7474
base_t, *other_ts = times_no_warmup
@@ -79,7 +79,7 @@ def build_row(bench_name)
7979

8080
row = [bench_name, mean(base_t), 100 * stddev(base_t) / mean(base_t)]
8181
row << base_rss if @include_rss
82-
82+
8383
other_ts.zip(other_rsss).each do |other_t, other_rss|
8484
row += [mean(other_t), 100 * stddev(other_t) / mean(other_t)]
8585
row << other_rss if @include_rss
@@ -90,6 +90,25 @@ def build_row(bench_name)
9090
row
9191
end
9292

93+
def extract_first_iteration_times(bench_name)
94+
@executable_names.map do |name|
95+
data = bench_data_for(name, bench_name)
96+
(data['warmup'][0] || data['bench'][0]) * 1000.0
97+
end
98+
end
99+
100+
def extract_benchmark_times(bench_name)
101+
@executable_names.map do |name|
102+
bench_data_for(name, bench_name)['bench'].map { |v| v * 1000.0 }
103+
end
104+
end
105+
106+
def extract_rss_values(bench_name)
107+
@executable_names.map do |name|
108+
bench_data_for(name, bench_name)['rss'] / 1024.0 / 1024.0
109+
end
110+
end
111+
93112
def bench_data_for(name, bench_name)
94113
@bench_data[name][bench_name]
95114
end

0 commit comments

Comments
 (0)