Class: Corkscrews::Analysis
- Inherits:
-
Object
- Object
- Corkscrews::Analysis
- Defined in:
- lib/corkscrews/analysis.rb
Defined Under Namespace
Classes: Run
Constant Summary collapse
- SPEEDUPS =
(0..95).step(5).to_a.freeze
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#runs ⇒ Object
readonly
Returns the value of attribute runs.
Class Method Summary collapse
Instance Method Summary collapse
- #aggregate ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(events) ⇒ Analysis
constructor
A new instance of Analysis.
- #target_curve(file: nil, line: nil, kind: "line", name: nil) ⇒ Object
Constructor Details
#initialize(events) ⇒ Analysis
Returns a new instance of Analysis.
29 30 31 32 |
# File 'lib/corkscrews/analysis.rb', line 29 def initialize(events) @events = events @runs = build_runs(events) end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
34 35 36 |
# File 'lib/corkscrews/analysis.rb', line 34 def events @events end |
#runs ⇒ Object (readonly)
Returns the value of attribute runs.
34 35 36 |
# File 'lib/corkscrews/analysis.rb', line 34 def runs @runs end |
Class Method Details
.load(path) ⇒ Object
14 15 16 |
# File 'lib/corkscrews/analysis.rb', line 14 def load(path) new(parse_events(path)) end |
Instance Method Details
#aggregate ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/corkscrews/analysis.rb', line 40 def aggregate { run_count: @runs.length, duration_ns: @runs.sum(&:duration_ns), total_samples: @runs.sum { |run| run.samples.values.sum { |value| value[:samples] } }, progress: aggregate_progress, latency: aggregate_latency, native: aggregate_native, runtime: aggregate_runtime, rounds: aggregate_rounds, targets: aggregate_targets } end |
#empty? ⇒ Boolean
36 37 38 |
# File 'lib/corkscrews/analysis.rb', line 36 def empty? @runs.empty? end |
#target_curve(file: nil, line: nil, kind: "line", name: nil) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/corkscrews/analysis.rb', line 54 def target_curve(file: nil, line: nil, kind: "line", name: nil) target = aggregate_targets.find do |candidate| if kind.to_s == "wait" candidate[:kind] == "wait" && candidate[:name] == name.to_s else candidate[:kind] == "line" && File.(candidate[:file]) == File.(file) && candidate[:line].to_i == line.to_i end end target&.fetch(:curve) end |