code_timer_helper.rb
module CodeTimerHelper
# Creates a CodeTimer section around the method
#
def timed_method(timer, method_name, section_name = method_name.to_s)
eigenclass = (class << self; self; end)
eigenclass.class_eval do
define_method method_name do |*args, &block|
timer.start(section_name)
begin
super(*args, &block)
ensure
timer.stop(section_name)
end
end
end
end
end
No comments:
Post a Comment