Skip to content

Instantly share code, notes, and snippets.

@headius
Created January 17, 2010 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save headius/279475 to your computer and use it in GitHub Desktop.
Save headius/279475 to your computer and use it in GitHub Desktop.
diff --git a/lib/rack/runtime.rb b/lib/rack/runtime.rb
index 1bd411f..e247d4f 100644
--- a/lib/rack/runtime.rb
+++ b/lib/rack/runtime.rb
@@ -12,10 +12,12 @@ module Rack
@header_name << "-#{name}" if name
end
+ require 'java'
def call(env)
- start_time = Time.now
+ start_time = java.lang.System.nano_time
status, headers, body = @app.call(env)
- request_time = Time.now - start_time
+ request_time = java.lang.System.nano_time - start_time
+ request_time /= 1_000_000_000.0
if !headers.has_key?(@header_name)
headers[@header_name] = "%0.6f" % request_time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment