Skip to content

Commit

Permalink
clarifying latency logging by adding units and removing timer latency…
Browse files Browse the repository at this point in the history
… itself
  • Loading branch information
trumant committed Apr 23, 2012
1 parent 11c996b commit 586d365
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/goliath/plugins/latency.rb
Expand Up @@ -6,6 +6,10 @@ module Plugin
# plugin Goliath::Plugin::Latency
#
class Latency

# Number of seconds to wait before logging latency
LATENCY_TIMING = 1

# Called by the framework to initialize the plugin
#
# @param port [Integer] Unused
Expand All @@ -28,9 +32,9 @@ def self.recent_latency

# Called automatically to start the plugin
def run
EM.add_periodic_timer(1) do
@@recent_latency = (Time.now.to_f - @last)
@logger.info "LATENCY: #{@@recent_latency}"
EM.add_periodic_timer(LATENCY_TIMING) do
@@recent_latency = ((Time.now.to_f - @last) - LATENCY_TIMING)
@logger.info "LATENCY: #{(@@recent_latency * 1000)} ms"
@last = Time.now.to_f
end
end
Expand Down

0 comments on commit 586d365

Please sign in to comment.