Sha256: 8031452f229658381ef05c5b6af6cecad91ef61cd9e8feeb972bb12ba1443320

Contents?: true

Size: 445 Bytes

Versions: 4

Compression:

Stored size: 445 Bytes

Contents

require 'hairballs'

# Quick and dirty benchmarking of whatever block you pass to the method.
#
# @see http://stackoverflow.com/a/123834/172106
Hairballs.add_plugin(:quick_benchmark) do |plugin|
  plugin.libraries %w(benchmark)

  plugin.on_load do
    Kernel.module_eval do
      def quick_benchmark(repetitions=100, &block)
        Benchmark.bmbm do |b|
          b.report { repetitions.times(&block) }
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hairballs-0.1.3 lib/hairballs/plugins/quick_benchmark.rb
hairballs-0.1.2 lib/hairballs/plugins/quick_benchmark.rb
hairballs-0.1.1 lib/hairballs/plugins/quick_benchmark.rb
hairballs-0.1.0 lib/hairballs/plugins/quick_benchmark.rb