Sha256: b8a9536abaf7370217c55d344d261d7c23093aa07fe3ce9f0b6e3c30b02d5a00

Contents?: true

Size: 697 Bytes

Versions: 1

Compression:

Stored size: 697 Bytes

Contents

require 'benchmark'

module Benchmark
  @cases = []
  @after_callbacks = []
  @before_callbacks = []

  class << self
    attr_reader :cases
    attr_reader :before_callbacks
    attr_reader :after_callbacks

    alias _measure measure

    def before(&block)
      before_callbacks << block
    end

    def after(&block)
      after_callbacks << block
    end

    def measure(*args, &block)
      before_callbacks.each &:call
      result = _measure(*args, &block)
      after_callbacks.each &:call
      result
    end
  end
end

def before(&block)
  Benchmark.before &block
end

def after(&block)
  Benchmark.after &block
end

def profile(name, &block)
  Benchmark.cases << [name, block]
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/bundler/gems/moped-cf817ca58a85/perf/helpers.rb