Created
January 17, 2010 18:04
-
-
Save headius/279475 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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