Module: Polyrun::Timing::Summary
- Defined in:
- lib/polyrun/timing/summary.rb
Overview
Human-readable slow-file list from merged timing JSON (per-file cost).
Class Method Summary collapse
-
.format_slow_files(merged, top: 30, title: "Polyrun slowest files (by wall time, seconds)") ⇒ Object
mergedis path (String) => seconds (Float) or stats Hash, as produced byTiming::Merge.merge_files. - .write_file(merged, path, **kwargs) ⇒ Object
Class Method Details
.format_slow_files(merged, top: 30, title: "Polyrun slowest files (by wall time, seconds)") ⇒ Object
merged is path (String) => seconds (Float) or stats Hash, as produced by Timing::Merge.merge_files.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/polyrun/timing/summary.rb', line 10 def format_slow_files(merged, top: 30, title: "Polyrun slowest files (by wall time, seconds)") return "#{title}\n (no data)\n" if merged.nil? || merged.empty? pairs = merged.map { |path, sec| [path, Stats.binpack_weight(sec)] } .sort_by { |(_, sec)| -sec.to_f }.first(Integer(top)) lines = [title, ""] pairs.each_with_index do |(path, sec), i| lines << format(" %2d. %s %.4f", i + 1, path, sec.to_f) end lines.join("\n") + "\n" end |
.write_file(merged, path, **kwargs) ⇒ Object
22 23 24 25 |
# File 'lib/polyrun/timing/summary.rb', line 22 def write_file(merged, path, **kwargs) File.write(path, format_slow_files(merged, **kwargs)) path end |