class Benchmark::Sweet::Item
borrowed heavily from Benchmark::IPS::Job::Entry may be able to fallback on that - will need to generate a &block friendly proc for that structure
Attributes
action[R]
label[R]
Public Class Methods
new(label, action = nil)
click to toggle source
# File lib/benchmark/sweet/item.rb, line 7 def initialize(label, action = nil) @label = label @action = action || @label[:method] #raise("Item needs an action") end
Public Instance Methods
block()
click to toggle source
# File lib/benchmark/sweet/item.rb, line 12 def block @block ||= action.kind_of?(String) ? compile(action) : action end
compile(str)
click to toggle source
to use with Job::Entry… def call_once ; call_times(1) ; end def callback_proc
lambda(&method(:call_once))
end
# File lib/benchmark/sweet/item.rb, line 21 def compile(str) eval <<-CODE Proc.new do #{str} end CODE end