Module: Profiler::ObjectExt
- Defined in:
- lib/simple-profiler.rb
Instance Method Summary collapse
Instance Method Details
#profile(symbol) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/simple-profiler.rb', line 3 def profile(symbol) _symbol = ("_rm_profile_" + symbol.to_s).to_sym alias_method _symbol, symbol self.send(:define_method, symbol.to_s) do |*args| clazz_name = self.send(:class).to_s method_name = symbol.to_s start_time = Time.now result = self.send(_symbol, *args) end_time = Time.now profile_log(clazz_name, method_name, start_time, end_time) result end end |
#profile_log(clazz_name, method_name, start_time, end_time) ⇒ Object
21 22 23 |
# File 'lib/simple-profiler.rb', line 21 def profile_log(clazz_name, method_name, start_time, end_time) puts "%s#%s runtime: %.5f s" % [clazz_name, method_name, (end_time-start_time).to_f] end |