From 2816f3ceaa31452f6bb67a7a7297e6795221cb35 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 24 Dec 2010 15:41:53 -0800 Subject: use clock_gettime for time resolution This lets us use CLOCK_MONOTONIC so we are not affected by system clock changes. We still convert to microseconds instead of nanoseconds for (pure)-Ruby 1.8 code compatibility. There is also little need for nanosecond timer resolution in log files (microsecond is not needed, even). --- test/test_clogger.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test') diff --git a/test/test_clogger.rb b/test/test_clogger.rb index 9252a42..47387bb 100644 --- a/test/test_clogger.rb +++ b/test/test_clogger.rb @@ -647,4 +647,14 @@ class TestClogger < Test::Unit::TestCase Clogger.new(app, :logger=> $stderr, :path => tmp.path) } end + + def test_request_time + s = [] + app = lambda { |env| sleep(0.1) ; [302, [], [] ] } + cl = Clogger.new(app, :logger => s, :format => "$request_time") + status, headers, body = cl.call(@req) + assert_nothing_raised { body.each { |x| } ; body.close } + assert s[-1].to_f >= 0.100 + assert s[-1].to_f <= 0.110 + end end -- cgit v1.2.3-24-ge0c7