Module: Kernel

Defined in:
lib/rbvmomi/profile.rb

Overview

Copyright © 2010 VMware, Inc. All Rights Reserved.

Constant Summary collapse

PROFILE_TIMES =
Hash.new 0.0

Instance Method Summary collapse

Instance Method Details

#dump_profileObject



15
16
17
18
19
# File 'lib/rbvmomi/profile.rb', line 15

def dump_profile
  PROFILE_TIMES.sort_by { |k,v| -v }.each do |sym,total|
    puts "#{sym} #{total}"
  end
end

#profile(sym, &b) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/rbvmomi/profile.rb', line 6

def profile sym, &b
  start_time = Time.now
  ret = b.call
  elapsed = Time.now - start_time
  PROFILE_TIMES[sym] += elapsed
  puts "#{sym} #{elapsed}s" if $profile
  ret
end