Sha256: 4719c175ee7664073b0cc0e93f4da31d9fed541bf75bc41ab74588733f7b1e09
Contents?: true
Size: 846 Bytes
Versions: 3
Compression:
Stored size: 846 Bytes
Contents
class Quandl::Client::Base module Benchmark extend ActiveSupport::Concern included do benchmark(:save) end module ClassMethods def benchmark(*names) names.each do |name| def_benchmark(name) end end private def def_benchmark(name) define_method(name) do |*args, &block| benchmark(name) do super(*args, &block) if defined?(super) end end end end def human_benchmarks benchmarks.sort_by{|k,v| v }.reverse.collect{|k,v| "#{k}: #{v.microseconds}ms" }.join(' | ') end def benchmarks @benchmarks ||= {} end private def benchmark(name, &block) timer = Time.now result = block.call self.benchmarks[name.to_sym] ||= timer.elapsed result end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
quandl_client-2.13.0 | lib/quandl/client/base/benchmark.rb |
quandl_client-2.12.0 | lib/quandl/client/base/benchmark.rb |
quandl_client-2.11.0 | lib/quandl/client/base/benchmark.rb |