Skip to content

Commit c54a474

Browse files
authored
Merge pull request #254 from fastruby/feature/across-rubies-readability
Across Rubies: charts and cards that say what happened
2 parents 06c3bc9 + ebfaed3 commit c54a474

2 files changed

Lines changed: 267 additions & 80 deletions

File tree

‎script/build_results_site.rb‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,25 +172,29 @@ def entry(report, name)
172172
report["entries"].find { |e| e["name"] == name }
173173
end
174174

175-
# Per report: [i/s, error, relative to the reference's median]. Relative is nil for a suspect or zero result, or a report the reference does not have.
175+
# Per report: [i/s, error, relative to the reference's median of the claimed report].
176+
# Every report of a benchmark shares that one baseline, so on the chart the higher line is the faster report.
177+
# Relative is nil for a suspect or zero result, or when the reference has no usable pass of the claimed report.
176178
def cross_run(report, names, ref_ips)
177179
entries = names.each_with_index.map do |name, i|
178180
e = entry(report, name) or next nil
179-
rel = ref_ips[i].empty? || !e["ips"].positive? || e["ips"] > SUSPECT_IPS ? nil : (e["ips"] / median(ref_ips[i])).round(4)
181+
rel = ref_ips[0].empty? || !e["ips"].positive? || e["ips"] > SUSPECT_IPS ? nil : sig(e["ips"] / median(ref_ips[0]))
180182
[e["ips"].round(3), e["error"].to_f.round(1), rel]
181183
end
182184
{ entries: entries, pass: report["pass"] }
183185
end
184186

185-
# The reference itself: its median pass, 1.0 relative to itself.
187+
# The reference itself: its median pass, relative to its own claimed report (1.0 for the claimed report).
186188
def reference_run(passes, names, ref_ips)
187189
entries = names.each_with_index.map do |name, i|
188190
es = passes.filter_map { |r| entry(r, name) }
189191
next nil if es.empty?
190192

191193
usable = es.select { |e| e["ips"].positive? && e["ips"] <= SUSPECT_IPS }
192194
pick = usable.empty? ? es : usable
193-
[median(pick.map { |e| e["ips"] }).round(3), median(pick.map { |e| e["error"].to_f }).round(1), ref_ips[i].empty? ? nil : 1.0]
195+
ips = median(pick.map { |e| e["ips"] })
196+
rel = ref_ips[0].empty? || ref_ips[i].empty? ? nil : sig(median(ref_ips[i]) / median(ref_ips[0]))
197+
[ips.round(3), median(pick.map { |e| e["error"].to_f }).round(1), rel]
194198
end
195199
{ entries: entries, passes: passes.map { |r| r["pass"] }.sort }
196200
end
@@ -204,6 +208,11 @@ def variation(ref_ips)
204208
cvs.empty? ? nil : median(cvs)
205209
end
206210

211+
# Four significant digits: a report 27M times slower than the claimed one keeps its value instead of rounding to 0.
212+
def sig(value)
213+
Float(format("%.4g", value))
214+
end
215+
207216
def median(values)
208217
s = values.sort
209218
s.size.odd? ? s[s.size / 2] : (s[s.size / 2 - 1] + s[s.size / 2]) / 2.0

0 commit comments

Comments
 (0)