can't resist: http://shipilev.net/blog/2014/nanotrusting-nanotime/
Romain Manni-Bucau Twitter: @rmannibucau Blog: http://rmannibucau.wordpress.com/ LinkedIn: http://fr.linkedin.com/in/rmannibucau Github: https://github.com/rmannibucau 2014-07-15 17:58 GMT+02:00 Jean-Louis Monteiro <[email protected]>: > Definitely for measuring delay nanoTime is better and much more accurate > than timeMillis especially on non unix machins. > > > > -- > Jean-Louis Monteiro > http://twitter.com/jlouismonteiro > http://www.tomitribe.com > > > On Tue, Jul 15, 2014 at 5:51 PM, <[email protected]> wrote: > >> Author: andygumbrecht >> Date: Tue Jul 15 15:51:08 2014 >> New Revision: 1610729 >> >> URL: http://svn.apache.org/r1610729 >> Log: >> 1ms is quite a long time >> >> Modified: >> >> tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/test/java/org/apache/openejb/core/singleton/AsyncPostContructTest.java >> >> Modified: >> tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/test/java/org/apache/openejb/core/singleton/AsyncPostContructTest.java >> URL: >> http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/test/java/org/apache/openejb/core/singleton/AsyncPostContructTest.java?rev=1610729&r1=1610728&r2=1610729&view=diff >> >> ============================================================================== >> --- >> tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/test/java/org/apache/openejb/core/singleton/AsyncPostContructTest.java >> (original) >> +++ >> tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/test/java/org/apache/openejb/core/singleton/AsyncPostContructTest.java >> Tue Jul 15 15:51:08 2014 >> @@ -16,10 +16,12 @@ >> */ >> package org.apache.openejb.core.singleton; >> >> +import org.apache.openejb.OpenEJB; >> import org.apache.openejb.jee.EnterpriseBean; >> import org.apache.openejb.jee.SingletonBean; >> import org.apache.openejb.junit.ApplicationComposer; >> import org.apache.openejb.testing.Module; >> +import org.junit.AfterClass; >> import org.junit.Test; >> import org.junit.runner.RunWith; >> >> @@ -38,6 +40,12 @@ import static org.testng.Assert.assertTr >> >> @RunWith(ApplicationComposer.class) >> public class AsyncPostContructTest { >> + >> + @AfterClass >> + public static void afterClass() throws Exception { >> + OpenEJB.destroy(); >> + } >> + >> @EJB >> private BuildMeAsync buildMeAsync; >> >> @@ -50,9 +58,9 @@ public class AsyncPostContructTest { >> >> @Test >> public void postConstructShouldEndsBeforeAsyncCall() { >> - final long start = buildMeAsync.getStartEnd(); >> + final long constructed = buildMeAsync.getStartEnd(); >> final long async = buildMeAsync.getAsyncStart(); >> - assertTrue(async > start); >> + assertTrue(async >= constructed); >> assertSame(buildMeAsync.getAsyncInstance(), >> buildMeAsync.getAsyncInstance()); >> } >> >> @@ -77,12 +85,12 @@ public class AsyncPostContructTest { >> } catch (final InterruptedException e) { >> // no-op >> } >> - startEnd = System.currentTimeMillis(); >> + startEnd = System.nanoTime(); >> } >> >> @Asynchronous >> public Future<Boolean> async() { >> - asyncStart = System.currentTimeMillis(); >> + asyncStart = System.nanoTime(); >> asyncInstance = this; >> return new AsyncResult<Boolean>(true); >> } >> >> >>
