Sha256: 0190e2fee0361e8c8f2b571744e679f3a3cca28ce28e7d9b975b810a7af3a840
Contents?: true
Size: 1.25 KB
Versions: 6
Compression:
Stored size: 1.25 KB
Contents
require 'benchmark/ips' module Vedeu module Logging module Debug # Provide wrapper for 'benchmark-ips' gem. # class IPS attr_accessor :samples attr_accessor :benchmark # @return [Vedeu::Logging::Debug::IPS] def initialize @old_stdout = $stdout $stdout = StringIO.new @samples = {} @benchmark = Benchmark::IPS::Job.new @count = 0 end # @param label [String] # @return [void] def add_item(label = '', &blk) samples[label] = blk @count += 1 benchmark.item(label, &blk) end # @return [void] 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}") $stdout = @old_stdout Vedeu.log(type: :debug, message: "Running: #{key}") samples[key].call end private # @return [void] def key @key ||= samples.keys.sample end end # IPS end # Debug end # Logging end # Vedeu
Version data entries
6 entries across 6 versions & 1 rubygems