Clockblock
Extend Clockblock::Timing in your class definition to add timers to your methods:
require 'clockblock'
class Foo
extend Clockblock::Timing
add_timing_to :bar
def bar
sleep 2
end
end
f = Foo.new
f.bar
f.clockblock_timers[:bar]
Extend your instances with Clockblock::Timing to add timers to your methods:
require 'clockblock'
class Foo
def bar
sleep 2
end
end
f = Foo.new
f.extend Clockblock::Timing
f.add_timing_to :bar
f.bar
f.clockblock_timers[:bar]
Extend your classes with Clockblock::Timing to add timers to your methods:
require 'clockblock'
class Foo
def bar
sleep 2
end
end
Foo.extend Clockblock::Timing
Foo.add_timing_to :bar, :baz
puts Foo.instance_variable_get(:@future_timer_methods)
class Foo; def baz; sleep 2; end; end
f = Foo.new
f.bar
f.baz
puts f.clockblock_timers
Wrap your code in a Clockblock clock block to measure execution duration.
require 'clockblock'
class Foo
def bar
t = Clockblock::Timer.new
result = t.clock do
sleep 2
end
puts t.attributes
result
end
end