27import java.time.Instant;
28import java.time.ZoneOffset;
29import java.time.temporal.ChronoUnit;
31import org.jau.io.PrintUtil;
32import org.jau.sys.Clock;
33import org.junit.Assert;
34import org.junit.FixMethodOrder;
36import org.junit.runners.MethodSorters;
38import jau.pkg.PlatformRuntime;
39import jau.test.junit.util.JunitTracer;
41@FixMethodOrder(MethodSorters.NAME_ASCENDING)
56 }
catch (
final InterruptedException e) { }
63 final long m_t0_d = m_t0.until(m_t0_b, ChronoUnit.MILLIS);
64 final long m_t1_d = m_t1.until(m_t1_b, ChronoUnit.MILLIS);
65 final long w_t2_d = w_t2.until(w_t2_b, ChronoUnit.MILLIS);
66 final long w_t3_d = w_t3.until(w_t3_b, ChronoUnit.MILLIS);
68 PrintUtil.
fprintf_td(System.err,
"mono t0 %s, %d ms\n", m_t0.atZone(ZoneOffset.UTC), m_t0_d);
69 PrintUtil.
fprintf_td(System.err,
"mono t1 %s, %d ms\n", m_t1.atZone(ZoneOffset.UTC), m_t1_d);
70 PrintUtil.
fprintf_td(System.err,
"wall t2 %s, %d ms\n", w_t2.atZone(ZoneOffset.UTC), w_t2_d);
71 PrintUtil.
fprintf_td(System.err,
"wall t3 %s, %d ms\n", w_t3.atZone(ZoneOffset.UTC), w_t3_d);
73 final long td_min = 50;
74 final long td_max = 150;
75 Assert.assertTrue( td_min <= m_t0_d );
76 Assert.assertTrue( td_max >= m_t0_d );
78 Assert.assertTrue( td_min <= m_t1_d );
79 Assert.assertTrue( td_max >= m_t1_d );
81 Assert.assertTrue( 0 <= w_t2_d );
82 Assert.assertTrue( 1000 >= w_t2_d );
84 Assert.assertTrue( td_min <= w_t3_d );
85 Assert.assertTrue( td_max >= w_t3_d );
88 public static void main(
final String args[]) {
90 org.junit.runner.JUnitCore.
main(tstname);
static void main(final String args[])
static void fprintf_td(final PrintStream out, final String format, final Object ... args)
Convenient PrintStream#printf(String, Object...) invocation, prepending the elapsedTimeMillis() times...
static Instant getWallClockTime()
Returns current wall-clock real-time since Unix Epoch 00:00:00 UTC on 1970-01-01.
static native long currentTimeMillis()
Returns current monotonic time in milliseconds.
static Instant getMonotonicTime()
Returns current monotonic time since Unix Epoch 00:00:00 UTC on 1970-01-01.
static native long wallClockSeconds()
Returns current wall-clock system time of day in seconds since Unix Epoch 00:00:00 UTC on 1 January 1...