module OverallRequestTimes::Timer

Attributes

remote_app_name[R]

Public Instance Methods

add(some_time) click to toggle source
# File lib/overall_request_times/timer.rb, line 32
def add(some_time)
  @timer_mutex.synchronize do
    @counter += 1
    @total += some_time
  end
end
call_count() click to toggle source
# File lib/overall_request_times/timer.rb, line 19
def call_count
  @timer_mutex.synchronize do
    @counter
  end
end
reset!() click to toggle source
# File lib/overall_request_times/timer.rb, line 25
def reset!
  @timer_mutex.synchronize do
    @total = 0
    @counter = 0
  end
end
start() click to toggle source
# File lib/overall_request_times/timer.rb, line 39
def start
  @started_at = Time.now
end
stop() click to toggle source
# File lib/overall_request_times/timer.rb, line 43
def stop
  return unless @started_at
  ended_at = Time.now
  add(ended_at.to_f - @started_at.to_f)
end
timer_setup(remote_app_name, in_mutex = false) click to toggle source
# File lib/overall_request_times/timer.rb, line 6
def timer_setup(remote_app_name, in_mutex = false)
  @remote_app_name = remote_app_name
  @timer_mutex = Mutex.new
  reset!
  OverallRequestTimes.register(self) unless in_mutex
end
total() click to toggle source
# File lib/overall_request_times/timer.rb, line 13
def total
  @timer_mutex.synchronize do
    @total
  end
end