Class: TestProf::Autopilot::EventProf::Report

Inherits:
Object
  • Object
show all
Extended by:
ReportBuilder
Defined in:
lib/test_prof/autopilot/event_prof/report.rb

Overview

:event_prof report allows to add additional functionality for it’s instances

Constant Summary collapse

ARTIFACT_FILE =
"event_prof_report.json"

Constants included from ReportBuilder

ReportBuilder::ARTIFACT_MISSING_HINT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ReportBuilder

build

Constructor Details

#initialize(raw_report) ⇒ Report

Returns a new instance of Report.



20
21
22
23
# File 'lib/test_prof/autopilot/event_prof/report.rb', line 20

def initialize(raw_report)
  @type = :event_prof
  @raw_report = raw_report
end

Instance Attribute Details

#raw_reportObject (readonly)

Returns the value of attribute raw_report.



18
19
20
# File 'lib/test_prof/autopilot/event_prof/report.rb', line 18

def raw_report
  @raw_report
end

#typeObject (readonly)

Returns the value of attribute type.



18
19
20
# File 'lib/test_prof/autopilot/event_prof/report.rb', line 18

def type
  @type
end

Instance Method Details

#merge(other) ⇒ Object

Raises:

  • (ArgumentError)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/test_prof/autopilot/event_prof/report.rb', line 29

def merge(other)
  raise ArgumentError, "Incompatible events: #{raw_report["event"]} and #{other.raw_report["event"]}" if raw_report["event"] != other.raw_report["event"]

  report = raw_report.dup

  %w[total_time absolute_run_time total_count].each do |field|
    report[field] += other.raw_report[field]
  end

  report["time_percentage"] = (report["total_time"] / report["absolute_run_time"]) * 100

  report["groups"] = (report["groups"] + other.raw_report["groups"]).sort { |a, b| b["time"] <=> a["time"] }.take(report["top_count"])

  Report.new(report)
end

#pathsObject



25
26
27
# File 'lib/test_prof/autopilot/event_prof/report.rb', line 25

def paths
  @raw_report["groups"].reduce("") { |paths, group| "#{paths} #{group["location"]}" }.strip
end