Class: Benchmarkable::BenchmarkReport
- Inherits:
-
Object
- Object
- Benchmarkable::BenchmarkReport
- Defined in:
- lib/benchmarkable.rb
Defined Under Namespace
Classes: Data
Instance Method Summary collapse
Instance Method Details
#add_entry_for(description) ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/benchmarkable.rb', line 76 def add_entry_for(description) result = nil call_stack << [] data = Data.new(description) do result = yield end call_stack.pop.each {|nested_call_data| data << nested_call_data } call_stack.last << data result end |
#entries(options = {}) ⇒ Object
96 97 98 99 100 |
# File 'lib/benchmarkable.rb', line 96 def entries( = {}) starting_context = [:starting_context].to_a || [] nesting_limit = [:nesting_limit] == :none ? call_stack.first.collect {|data| data.nested_levels }.max : [:nesting_limit] || 0 call_stack.first.collect {|data| data.to_entry(starting_context, nesting_limit) }.flatten end |
#to_csv(options = {}) ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/benchmarkable.rb', line 87 def to_csv( = {}) = {:force_quotes => true, :encoding => 'U'}.merge(.delete(:csv_options) || {}) FasterCSV.generate() do |csv| entries().each do |entry| csv << [entry[:timestamp].to_s, entry[:context], entry[:execution_time].real].flatten end end end |