Class: LdapSearchProfiler::Timer

Inherits:
Object
  • Object
show all
Defined in:
lib/ldapmodel/profiler.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Timer) initialize

Returns a new instance of Timer



18
19
20
21
# File 'lib/ldapmodel/profiler.rb', line 18

def initialize
  @started = Time.now
  @duration = 0
end

Instance Attribute Details

- (Object) duration

Returns the value of attribute duration



17
18
19
# File 'lib/ldapmodel/profiler.rb', line 17

def duration
  @duration
end

Instance Method Details

- (Object) stop(msg = "")



23
24
25
26
27
28
29
# File 'lib/ldapmodel/profiler.rb', line 23

def stop(msg="")
  if ENV["LDAP_PROFILER"]
    color = :blue
    @duration = (Time.now - @started).to_f * 1000
    puts "#{ msg } in #{ @duration } ms".colorize(color)
  end
end