Class: TestProf::Autopilot::FactoryProf::Writer

Inherits:
ReportWriter
  • Object
show all
Defined in:
lib/test_prof/autopilot/factory_prof/writer.rb

Overview

Class is used for writing :factory_prof report in different formats

Constant Summary collapse

ARTIFACT_FILE =
"factory_prof_report"

Instance Attribute Summary

Attributes inherited from ReportWriter

#report

Instance Method Summary collapse

Methods inherited from ReportWriter

#initialize, #write, write_report

Methods included from Logging

log

Constructor Details

This class inherits a constructor from TestProf::Autopilot::ReportWriter

Instance Method Details

#generate_htmlObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/test_prof/autopilot/factory_prof/writer.rb', line 16

def generate_html
  result = report.result

  report_data = {
    total_stacks: result.stacks.size,
    total: result.total_count
  }

  report_data[:roots] = TestProf::FactoryProf::Printers::Flamegraph.convert_stacks(result)

  path = TestProf::Utils::HTMLBuilder.generate(
    data: report_data,
    template: TestProf::FactoryProf::Printers::Flamegraph::TEMPLATE,
    output: TestProf::FactoryProf::Printers::Flamegraph::OUTPUT_NAME
  )

  File.read(path).tap do
    FileUtils.rm(path)
  end
end

#generate_jsonObject



12
13
14
# File 'lib/test_prof/autopilot/factory_prof/writer.rb', line 12

def generate_json
  report.result.to_json
end