Class: Corkscrews::Analysis

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#eventsObject (readonly)

Returns the value of attribute events.



34
35
36
# File 'lib/corkscrews/analysis.rb', line 34

def events
  @events
end

#runsObject (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

#aggregateObject



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

Returns:

  • (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.expand_path(candidate[:file]) == File.expand_path(file) &&
        candidate[:line].to_i == line.to_i
    end
  end

  target&.fetch(:curve)
end