Sha256: cf9ef23bc881e06dd67e9b520c4b6f82486a05b8b8a7fe6df30f621bce7f3332

Contents?: true

Size: 460 Bytes

Versions: 1

Compression:

Stored size: 460 Bytes

Contents

require_relative '../../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

1 entries across 1 versions & 1 rubygems

Version Path
hairballs-0.0.1 lib/hairballs/plugins/quick_benchmark.rb