@Override public JCGLTimerQueryUsableType getTimer() { if (this.timer.isPresent()) { return this.timer.get(); } final JCGLTimerQueryType t = JCGLProfiling.this.timers.timerQueryAllocate(); this.timer = Optional.of(t); return t; }
@Test public final void testOrdering() throws Exception { final JCGLTimersType g_t = this.getTimers("main"); final JCGLTimerQueryType q0 = g_t.timerQueryAllocate(); g_t.timerQueryBegin(q0); // Do some work to waste time g_t.timerQueryAllocate(); g_t.timerQueryAllocate(); g_t.timerQueryAllocate(); g_t.timerQueryAllocate(); g_t.timerQueryAllocate(); g_t.timerQueryFinish(q0); while (g_t.timerQueryResultAvailability(q0) == JCGLQueryResultAvailability.QUERY_RESULT_NOT_YET_AVAILABLE) { System.out.println("Waiting for q0: " + q0); Thread.sleep(1000L); } final long q0_r = g_t.timerQueryResultGet(q0); System.out.println("q0_r: " + q0_r); Assert.assertTrue(q0_r > 0); }
@Test public final void testOrdering() throws Exception { final JCGLTimersType g_t = this.getTimers("main"); final JCGLTimerQueryType q0 = g_t.timerQueryAllocate(); g_t.timerQueryBegin(q0); // Do some work to waste time g_t.timerQueryAllocate(); g_t.timerQueryAllocate(); g_t.timerQueryAllocate(); g_t.timerQueryAllocate(); g_t.timerQueryAllocate(); g_t.timerQueryFinish(q0); while (g_t.timerQueryResultAvailability(q0) == JCGLQueryResultAvailability.QUERY_RESULT_NOT_YET_AVAILABLE) { System.out.println("Waiting for q0: " + q0); Thread.sleep(1000L); } final long q0_r = g_t.timerQueryResultGet(q0); System.out.println("q0_r: " + q0_r); Assert.assertTrue(q0_r > 0); }
@Test public final void testFinishNotRunningOther() { final JCGLTimersType g_t = this.getTimers("main"); final JCGLTimerQueryType q0 = g_t.timerQueryAllocate(); final JCGLTimerQueryType q1 = g_t.timerQueryAllocate(); g_t.timerQueryBegin(q0); this.expected.expect(JCGLExceptionQueryNotRunning.class); g_t.timerQueryFinish(q1); } }
@Test public final void testBeginRunningOther() { final JCGLTimersType g_t = this.getTimers("main"); final JCGLTimerQueryType q0 = g_t.timerQueryAllocate(); final JCGLTimerQueryType q1 = g_t.timerQueryAllocate(); g_t.timerQueryBegin(q0); this.expected.expect(JCGLExceptionQueryAlreadyRunning.class); g_t.timerQueryBegin(q1); }
@Test public final void testBeginRunningOther() { final JCGLTimersType g_t = this.getTimers("main"); final JCGLTimerQueryType q0 = g_t.timerQueryAllocate(); final JCGLTimerQueryType q1 = g_t.timerQueryAllocate(); g_t.timerQueryBegin(q0); this.expected.expect(JCGLExceptionQueryAlreadyRunning.class); g_t.timerQueryBegin(q1); }
@Test public final void testFinishNotRunningOther() { final JCGLTimersType g_t = this.getTimers("main"); final JCGLTimerQueryType q0 = g_t.timerQueryAllocate(); final JCGLTimerQueryType q1 = g_t.timerQueryAllocate(); g_t.timerQueryBegin(q0); this.expected.expect(JCGLExceptionQueryNotRunning.class); g_t.timerQueryFinish(q1); } }
@Test public final void testNotAvailable() { final JCGLTimersType g_t = this.getTimers("main"); final JCGLTimerQueryType q = g_t.timerQueryAllocate(); Assert.assertEquals( JCGLQueryResultAvailability.QUERY_RESULT_NOT_YET_REQUESTED, g_t.timerQueryResultAvailability(q)); }
@Test public final void testFinishNotRunning() { final JCGLTimersType g_t = this.getTimers("main"); final JCGLTimerQueryType q = g_t.timerQueryAllocate(); this.expected.expect(JCGLExceptionQueryNotRunning.class); g_t.timerQueryFinish(q); }
@Test public final void testNotAvailable() { final JCGLTimersType g_t = this.getTimers("main"); final JCGLTimerQueryType q = g_t.timerQueryAllocate(); Assert.assertEquals( JCGLQueryResultAvailability.QUERY_RESULT_NOT_YET_REQUESTED, g_t.timerQueryResultAvailability(q)); }
@Test public final void testFinishNotRunning() { final JCGLTimersType g_t = this.getTimers("main"); final JCGLTimerQueryType q = g_t.timerQueryAllocate(); this.expected.expect(JCGLExceptionQueryNotRunning.class); g_t.timerQueryFinish(q); }
@Test public final void testBeginRunning() { final JCGLTimersType g_t = this.getTimers("main"); final JCGLTimerQueryType q = g_t.timerQueryAllocate(); g_t.timerQueryBegin(q); this.expected.expect(JCGLExceptionQueryAlreadyRunning.class); g_t.timerQueryBegin(q); }
@Test public final void testBeginRunning() { final JCGLTimersType g_t = this.getTimers("main"); final JCGLTimerQueryType q = g_t.timerQueryAllocate(); g_t.timerQueryBegin(q); this.expected.expect(JCGLExceptionQueryAlreadyRunning.class); g_t.timerQueryBegin(q); }
@Test public final void testIdentities() { final JCGLTimersType g_t = this.getTimers("main"); final JCGLTimerQueryType q = g_t.timerQueryAllocate(); Assert.assertFalse(q.isDeleted()); g_t.timerQueryDelete(q); Assert.assertTrue(q.isDeleted()); }
@Test public final void testIdentities() { final JCGLTimersType g_t = this.getTimers("main"); final JCGLTimerQueryType q = g_t.timerQueryAllocate(); Assert.assertFalse(q.isDeleted()); g_t.timerQueryDelete(q); Assert.assertTrue(q.isDeleted()); }
@Test public final void testDeleteDeleted() { final JCGLTimersType g_t = this.getTimers("main"); final JCGLTimerQueryType q = g_t.timerQueryAllocate(); Assert.assertFalse(q.isDeleted()); g_t.timerQueryDelete(q); Assert.assertTrue(q.isDeleted()); this.expected.expect(JCGLExceptionDeleted.class); g_t.timerQueryDelete(q); }
@Test public final void testDeleteDeleted() { final JCGLTimersType g_t = this.getTimers("main"); final JCGLTimerQueryType q = g_t.timerQueryAllocate(); Assert.assertFalse(q.isDeleted()); g_t.timerQueryDelete(q); Assert.assertTrue(q.isDeleted()); this.expected.expect(JCGLExceptionDeleted.class); g_t.timerQueryDelete(q); }