class ConsoleUtils::BenchUtils::Chips

Attributes

results[R]

Public Class Methods

method_missing(meth, *args, &blk) click to toggle source
Calls superclass method
# File lib/console_utils/bench_utils/chips.rb, line 11
def method_missing(meth, *args, &blk)
  shared.respond_to?(meth) ? shared.send(meth, *args, &blk) : super
end
new(reports = nil) click to toggle source

Creates Chips context using a given hash of reports.

Calls superclass method
# File lib/console_utils/bench_utils/chips.rb, line 23
def initialize(reports = nil)
  super(reports.to_h)
  @results = []
end
respond_to_missing?(*args) click to toggle source
Calls superclass method
# File lib/console_utils/bench_utils/chips.rb, line 15
def respond_to_missing?(*args)
  shared.respond_to?(*args) || super
end
shared() click to toggle source

The globally shared Chips object

# File lib/console_utils/bench_utils/chips.rb, line 7
def shared
  @shared ||= new
end

Public Instance Methods

call("label") { ...things to bench... } click to toggle source

Adds a labeled report block. The same as x.report(label) { ... }.

# File lib/console_utils/bench_utils/chips.rb, line 44
def call(name, &block)
  self[name] = block.to_proc
end
compare!() click to toggle source

Executes Benchmark.ips {|x| ...; x.compare! } using the given hash of procs as reports and push the result to results stack.

# File lib/console_utils/bench_utils/chips.rb, line 31
def compare!
  results << begin
    Benchmark.ips do |x|
      each_pair {|name, proc| x.report(name, &proc) }
      x.compare!
    end
  end
end
del(*args) click to toggle source
# File lib/console_utils/bench_utils/chips.rb, line 58
def del(*args)
  __getobj__.delete(*args)
end
recent() click to toggle source

Get a recent result

# File lib/console_utils/bench_utils/chips.rb, line 49
def recent
  results.last
end
split!(*args) click to toggle source

Splits reports to a new context

# File lib/console_utils/bench_utils/chips.rb, line 54
def split!(*args)
  Chips.new(__getobj__.split!(*args))
end