Class: Vedeu::Logging::Debug::IPS
- Inherits:
-
Object
- Object
- Vedeu::Logging::Debug::IPS
- Defined in:
- lib/vedeu/logging/ips.rb
Overview
Provide wrapper for ‘benchmark-ips’ gem.
Instance Attribute Summary collapse
-
#benchmark ⇒ Object
Returns the value of attribute benchmark.
-
#samples ⇒ Object
Returns the value of attribute samples.
Instance Method Summary collapse
- #add_item(label = '', &blk) ⇒ void
- #execute! ⇒ void
-
#initialize ⇒ Vedeu::Logging::Debug::IPS
constructor
Returns a new instance of Vedeu::Logging::Debug::IPS.
- #key ⇒ void private
Constructor Details
#initialize ⇒ Vedeu::Logging::Debug::IPS
Returns a new instance of Vedeu::Logging::Debug::IPS.
19 20 21 22 23 24 25 |
# File 'lib/vedeu/logging/ips.rb', line 19 def initialize @old_stdout = $stdout $stdout = StringIO.new @samples = {} @benchmark = Benchmark::IPS::Job.new @count = 0 end |
Instance Attribute Details
#benchmark ⇒ Object
Returns the value of attribute benchmark.
14 15 16 |
# File 'lib/vedeu/logging/ips.rb', line 14 def benchmark @benchmark end |
#samples ⇒ Object
Returns the value of attribute samples.
13 14 15 |
# File 'lib/vedeu/logging/ips.rb', line 13 def samples @samples end |
Instance Method Details
#add_item(label = '', &blk) ⇒ void
This method returns an undefined value.
29 30 31 32 33 34 |
# File 'lib/vedeu/logging/ips.rb', line 29 def add_item(label = '', &blk) samples[label] = blk @count += 1 benchmark.item(label, &blk) end |
#execute! ⇒ void
This method returns an undefined value.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vedeu/logging/ips.rb', line 37 def execute! benchmark.compare! benchmark.run_warmup benchmark.run $stdout.sync = true benchmark.run_comparison benchmark.full_report Vedeu.log(type: :debug, message: "IPS:\n#{$stdout.string}".freeze) $stdout = @old_stdout Vedeu.log(type: :debug, message: "Running: #{key}".freeze) samples[key].call end |
#key ⇒ void (private)
This method returns an undefined value.
56 57 58 |
# File 'lib/vedeu/logging/ips.rb', line 56 def key @key ||= samples.keys.sample end |