Class: Binpacker::Report
- Inherits:
-
Object
- Object
- Binpacker::Report
- Defined in:
- lib/binpacker/report.rb,
sig/binpacker/report.rbs
Overview
Builds the machine-readable Run report: predicted versus actual per-Worker durations plus the worst per-Test Drift. See docs/design/run-report-format.md.
Constant Summary collapse
- SCHEMA =
1- DRIFT_LIMIT =
10
Instance Method Summary collapse
-
#initialize(profile:, algorithm:, predicted_loads:, worker_stats:, all_timings:, timings:) ⇒ Report
constructor
A new instance of Report.
- #to_h ⇒ Hash[Symbol, untyped]
- #write(path) ⇒ Object
Constructor Details
#initialize(profile:, algorithm:, predicted_loads:, worker_stats:, all_timings:, timings:) ⇒ Report
Returns a new instance of Report.
12 13 14 15 16 17 18 19 |
# File 'lib/binpacker/report.rb', line 12 def initialize(profile:, algorithm:, predicted_loads:, worker_stats:, all_timings:, timings:) @profile = profile @algorithm = algorithm @predicted_loads = predicted_loads @worker_stats = worker_stats @all_timings = all_timings @timings = timings end |
Instance Method Details
#to_h ⇒ Hash[Symbol, untyped]
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/binpacker/report.rb', line 21 def to_h predicted = @predicted_loads actual = @worker_stats.map { |s| s[:total_time] } { schema: SCHEMA, profile: @profile, algorithm: @algorithm, worker_count: @worker_stats.size, predicted_makespan: round(predicted.max || 0.0), actual_makespan: round(actual.max || 0.0), workers: workers, balance: { predicted_deviation_pct: deviation_pct(predicted), actual_deviation_pct: deviation_pct(actual) }, drift: drift } end |
#write(path) ⇒ Object
41 42 43 |
# File 'lib/binpacker/report.rb', line 41 def write(path) File.write(path, JSON.pretty_generate(to_h)) end |