class Debug class << self def trace_methods klass klass.instance_methods(false).each do |m| klass.class_eval do alias_method :"old_#{m}", m define_method m.to_sym do |*args| begin time = Time.now p [m.to_sym, :start] result = send :"old_#{m}", *args ensure p [m.to_sym, :end, time - Time.now] end return result end end end end end end