Module: SchwadPerformanceLogger
- Defined in:
- lib/schwad_performance_logger.rb,
lib/schwad_performance_logger/version.rb
Constant Summary collapse
- VERSION =
"0.3.0"
Class Method Summary collapse
Class Method Details
.ips ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/schwad_performance_logger.rb', line 18 def self.ips Benchmark.ips do |x| x.report("PerformanceLogMethod") do suppress_output do yield end end end end |
.new(opts = {}) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/schwad_performance_logger.rb', line 10 def self.new(opts={}) if opts.is_a?(Hash) PLogger.new(opts) else puts "I'm sorry, I don't know what you're trying to pass here!\n\n Please refer to the docs or pass an options hash https://github.com/oceanshq/schwad_performance_logger" end end |
.time ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/schwad_performance_logger.rb', line 28 def self.time suppress_output do length_of_time = [] 10.times do start_time = Time.now yield length_of_time << Time.now - start_time end end puts "Average runtime #{length_of_time.sum / 10.0} seconds. Max time #{length_of_time.max}.seconds" end |