Class: Benchin::Wrap::Report
- Inherits:
-
Object
- Object
- Benchin::Wrap::Report
- Defined in:
- lib/benchin/wrap/report.rb,
lib/benchin/wrap/report/node.rb,
lib/benchin/wrap/report/node_printer.rb
Overview
Represents tree-like time measurement data produced by Benchin::Wrap.
See #to_h method for more concrete example.
Defined Under Namespace
Classes: Node, NodePrinter
Instance Method Summary collapse
-
#add_time(path, seconds) ⇒ Report
Adds seconds to a path in a tree and increases calls count by 1.
-
#initialize(name) ⇒ Report
constructor
A new instance of Report.
-
#to_h ⇒ Hash
Transforms report to a basic ruby types: arrays and hashes.
-
#to_s ⇒ String
Renders human readable report.
Constructor Details
Instance Method Details
#add_time(path, seconds) ⇒ Report
Adds seconds to a path in a tree and increases calls count by 1.
21 22 23 24 25 26 27 28 29 |
# File 'lib/benchin/wrap/report.rb', line 21 def add_time(path, seconds) target_node = path.reduce(@root) do |node, name| node.nested[name] ||= Node.new(name) end target_node.add_call(seconds) self end |
#to_h ⇒ Hash
Transforms report to a basic ruby types: arrays and hashes.
75 76 77 |
# File 'lib/benchin/wrap/report.rb', line 75 def to_h @root.to_h end |
#to_s ⇒ String
Renders human readable report.
82 83 84 |
# File 'lib/benchin/wrap/report.rb', line 82 def to_s NodePrinter.new(@root).to_s end |