Module: Ccp::Receivers::Profileable
Defined Under Namespace
Classes: Profile
Constant Summary
Constants included from Utils::Colorize::Fore
Utils::Colorize::Fore::BLACK, Utils::Colorize::Fore::BLUE, Utils::Colorize::Fore::CLEAR, Utils::Colorize::Fore::CYAN, Utils::Colorize::Fore::GREEN, Utils::Colorize::Fore::MAGENTA, Utils::Colorize::Fore::RED, Utils::Colorize::Fore::WHITE, Utils::Colorize::Fore::YELLOW
Instance Method Summary collapse
Methods included from Utils::Colorize
Methods included from Utils::Colorize::Fore
#aqua, #black, #blue, #colorize, #cyan, #green, #magenta, #pink, #purple, #red, #white, #yellow
Instance Method Details
#execute(cmd) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# 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 ⇒ Object
32 33 34 |
# File 'lib/ccp/receivers/profileable.rb', line 32 def profiles @profiles ||= [] end |
#show_profiles(*args, &block) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# 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 |