class Benchmark::IPS::Job::Entry
Entries in Benchmark Jobs.
def call_times(times)
-
(Integer)
- Number of times the +@action+ has been called.
Parameters:
-
times
(Integer
) -- Times to call +@action+.
def call_times(times) return @action.call(times) if @call_loop act = @action i = 0 while i < times act.call i += 1 end end
def compile(str)
-
(Symbol)
- :call_times.
Parameters:
-
str
(String
) -- Code to be compiled.
def compile(str) m = (class << self; self; end) code = <<-CODE def call_times(__total); __i = 0 while __i < __total #{str}; __i += 1 end end CODE m.class_eval code end
def initialize(label, action)
-
(ArgumentError)
- Raises when action is not String or not responding to +call+.
Parameters:
-
action
(String, Proc
) -- Code to be benchmarked. -
label
(#to_s
) -- Label of Benchmarked code.
def initialize(label, action) @label = label if action.kind_of? String compile action @action = self @as_action = true else unless action.respond_to? :call raise ArgumentError, "invalid action, must respond to #call" end @action = action if action.respond_to? :arity and action.arity > 0 @call_loop = true else @call_loop = false end @as_action = false end end