module Ccp::Receivers::Profileable
Constants
- Profile
Public Instance Methods
execute(cmd)
click to toggle source
Calls superclass method
# File lib/ccp/receivers/profileable.rb, line 17 def execute(cmd) start = Time.new super case cmd when Ccp::Commands::Composite # no profiles else profile = Profile.new(cmd, "execute", (Time.new - start).to_f) profiles << profile cmd.on_profiled(profile) if cmd.respond_to?(:on_profiled) end end
profiles()
click to toggle source
# File lib/ccp/receivers/profileable.rb, line 32 def profiles @profiles ||= [] end
show_profiles(*args, &block)
click to toggle source
# File lib/ccp/receivers/profileable.rb, line 36 def show_profiles(*args, &block) opts = Optionize.new(args, :benchs) benchs = opts[:benchs] || profiles # search worst item total = 0 worst = nil benchs.each do |bench| total += bench.time worst = bench if !worst or bench.time > worst.time end benchs.each do |bench| colorize = (bench == worst) ? :pink : :aqua profiled = __send__(colorize, bench.profile(total)) if block block.call(profiled) else logger.info profiled end end end