Sha256: 42b28ea5c84bec4c756aa2c2cea212dc5587bcb841f4fbb78d5f7cba0fccb4e2
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
require 'schwad_performance_logger/version' require 'csv' require 'logger' require 'get_process_mem' require 'benchmark/ips' require 'schwad_performance_logger/schwad_performance_logger' module SchwadPerformanceLogger 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 def self.ips Benchmark.ips do |x| x.report("PerformanceLogMethod") do suppress_output do yield end end end end 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 private def self.suppress_output original_stderr = $stderr.clone original_stdout = $stdout.clone $stderr.reopen(File.new('/dev/null', 'w')) $stdout.reopen(File.new('/dev/null', 'w')) yield ensure $stdout.reopen(original_stdout) $stderr.reopen(original_stderr) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
schwad_performance_logger-0.3.1 | lib/schwad_performance_logger.rb |