From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.140.141.15 with SMTP id o15cs360970rvd; Sun, 17 Jan 2010 11:22:21 -0800 (PST) Received: from mr.google.com ([10.150.172.17]) by 10.150.172.17 with SMTP id u17mr1505177ybe.1.1263756140815 (num_hops = 1); Sun, 17 Jan 2010 11:22:20 -0800 (PST) Received: by 10.150.172.17 with SMTP id u17mr76979ybe.1.1263756138987; Sun, 17 Jan 2010 11:22:18 -0800 (PST) X-BeenThere: rack-devel@googlegroups.com Received: by 10.150.39.12 with SMTP id m12ls703982ybm.2.p; Sun, 17 Jan 2010 11:22:17 -0800 (PST) Received: by 10.150.48.34 with SMTP id v34mr2634519ybv.10.1263756137201; Sun, 17 Jan 2010 11:22:17 -0800 (PST) Received: by 10.91.148.11 with SMTP id a11mr6941749ago.9.1263752400852; Sun, 17 Jan 2010 10:20:00 -0800 (PST) Received: by 10.91.148.11 with SMTP id a11mr6941748ago.9.1263752400820; Sun, 17 Jan 2010 10:20:00 -0800 (PST) Return-Path: Received: from mail-gx0-f200.google.com (mail-gx0-f200.google.com [209.85.217.200]) by gmr-mx.google.com with ESMTP id 24si309242yxe.11.2010.01.17.10.20.00; Sun, 17 Jan 2010 10:20:00 -0800 (PST) Received-SPF: pass (google.com: domain of headius@headius.com designates 209.85.217.200 as permitted sender) client-ip=209.85.217.200; Received: by gxk24 with SMTP id 24so6062084gxk.1 for ; Sun, 17 Jan 2010 10:20:00 -0800 (PST) MIME-Version: 1.0 Received: by 10.101.141.11 with SMTP id t11mr376369ann.42.1263752400727; Sun, 17 Jan 2010 10:20:00 -0800 (PST) Date: Sun, 17 Jan 2010 10:20:00 -0800 (PST) X-IP: 216.160.3.79 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-us) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10,gzip(gfe),gzip(gfe) Message-ID: <7ff49577-377c-4374-be17-e114391173a3@k17g2000yqh.googlegroups.com> Subject: Rack test spec_rack_runtime fails on JRuby due to timing From: Charles Oliver Nutter To: Rack Development Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: X-Thread-Url: http://groups.google.com/group/rack-devel/t/867a2dbeaf914afb X-Message-Url: http://groups.google.com/group/rack-devel/msg/eee8831f83c98c70 Sender: rack-devel@googlegroups.com List-Unsubscribe: , List-Subscribe: , Content-Type: text/plain; charset=ISO-8859-1 Hey, the following test currently fails on JRuby, but not for a very good reason: specify "should allow multiple timers to be set" do app = lambda { |env| sleep 0.1; [200, {'Content-Type' => 'text/ plain'}, "Hello, World!"] } runtime1 = Rack::Runtime.new(app, "App") runtime2 = Rack::Runtime.new(runtime1, "All") response = runtime2.call({}) response[1]['X-Runtime-App'].should =~ /[\d\.]+/ response[1]['X-Runtime-All'].should =~ /[\d\.]+/ Float(response[1]['X-Runtime-All']).should > Float(response[1]['X- Runtime-App']) end The test here is trying to time that the "All" timer is longer than the "App" timer. Unfortunately, when running on JRuby, the All time is often below 1ms, which is shorter than the granularity for our Time class (JVM only provides current time to 1ms granularity). As a result, the test usually fails. This came up because a friend of JRuby is working to prepare a Gentoo ebuild, and wants to get all related packages running green. I'm not sure the best way to fix this; the difference in execution time between the "App" and the "All" wrapper are very small, and a timing test like this is probably going to be unpredictable. I have made a JRuby-specific patch here to use the JVM's nanosecond timer (which can be used for deltas but not absolute times), but it's obviously JRuby-specific: http://gist.github.com/279475 Running the tests with this modification shows the "All" time to range around 0.00015s and the "App" time around 0.00003s. Thoughts? - Charlie