Mercurial > hg > graal-compiler
annotate graal/com.oracle.jvmci.debug.test/src/com/oracle/jvmci/debug/test/DebugTimerTest.java @ 21554:b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 26 May 2015 23:21:15 +0200 |
parents | graal/com.oracle.graal.debug.test/src/com/oracle/graal/debug/test/DebugTimerTest.java@fa75218e3942 |
children | f5b549811bac |
rev | line source |
---|---|
17174
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved. |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
21554
b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19693
diff
changeset
|
23 package com.oracle.jvmci.debug.test; |
17174
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 import static org.junit.Assert.*; |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
27 import java.lang.management.*; |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
28 |
17174
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 import org.junit.*; |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 |
21554
b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19693
diff
changeset
|
31 import com.oracle.jvmci.debug.*; |
b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19693
diff
changeset
|
32 |
17174
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 public class DebugTimerTest { |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
36 private static final ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean(); |
17174
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
38 /** |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
39 * Actively spins the current thread for at least a given number of milliseconds in such a way |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
40 * that timers for the current thread keep ticking over. |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
41 * |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
42 * @return the number of milliseconds actually spent spinning which is guaranteed to be >= |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
43 * {@code ms} |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
44 */ |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
45 private static long spin(long ms) { |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
46 long start = threadMXBean.getCurrentThreadCpuTime(); |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
47 do { |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
48 long durationMS = (threadMXBean.getCurrentThreadCpuTime() - start) / 1000; |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
49 if (durationMS >= ms) { |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
50 return durationMS; |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
51 } |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
52 } while (true); |
17350
95663a6385cf
DebugTimerTest: ignore on windows for now
Bernhard Urban <bernhard.urban@jku.at>
parents:
17174
diff
changeset
|
53 } |
95663a6385cf
DebugTimerTest: ignore on windows for now
Bernhard Urban <bernhard.urban@jku.at>
parents:
17174
diff
changeset
|
54 |
17174
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 @Test |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 public void test1() { |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 DebugConfig debugConfig = Debug.fixedConfig(0, 0, false, false, true, false, null, null, System.out); |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 try (DebugConfigScope dcs = new DebugConfigScope(debugConfig); Debug.Scope s = Debug.scope("DebugTimerTest")) { |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 DebugTimer timerA = Debug.timer("TimerA"); |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 DebugTimer timerB = Debug.timer("TimerB"); |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
63 long spinA; |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
64 long spinB; |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
65 |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
66 try (DebugCloseable a1 = timerA.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
67 spinA = spin(50); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
68 try (DebugCloseable b1 = timerB.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
69 spinB = spin(50); |
17174
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 Assert.assertTrue(timerB.getCurrentValue() < timerA.getCurrentValue()); |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 if (timerA.getFlat() != null && timerB.getFlat() != null) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
75 assertTrue(spinB >= spinA || timerB.getFlat().getCurrentValue() < timerA.getFlat().getCurrentValue()); |
17174
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 assertEquals(timerA.getFlat().getCurrentValue(), timerA.getCurrentValue() - timerB.getFlat().getCurrentValue(), 10D); |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 @Test |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 public void test2() { |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 DebugConfig debugConfig = Debug.fixedConfig(0, 0, false, false, true, false, null, null, System.out); |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 try (DebugConfigScope dcs = new DebugConfigScope(debugConfig); Debug.Scope s = Debug.scope("DebugTimerTest")) { |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 DebugTimer timerC = Debug.timer("TimerC"); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
86 try (DebugCloseable c1 = timerC.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
87 spin(50); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
88 try (DebugCloseable c2 = timerC.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
89 spin(50); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
90 try (DebugCloseable c3 = timerC.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
91 spin(50); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
92 try (DebugCloseable c4 = timerC.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
93 spin(50); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
94 try (DebugCloseable c5 = timerC.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
95 spin(50); |
17174
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
96 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
97 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
98 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
99 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
100 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
101 if (timerC.getFlat() != null) { |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
102 assertEquals(timerC.getFlat().getCurrentValue(), timerC.getCurrentValue()); |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
103 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
104 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
105 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
106 |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
107 @Test |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
108 public void test3() { |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
109 DebugConfig debugConfig = Debug.fixedConfig(0, 0, false, false, true, false, null, null, System.out); |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
110 try (DebugConfigScope dcs = new DebugConfigScope(debugConfig); Debug.Scope s = Debug.scope("DebugTimerTest")) { |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
111 |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
112 DebugTimer timerD = Debug.timer("TimerD"); |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
113 DebugTimer timerE = Debug.timer("TimerE"); |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
114 |
17357
d044ca4a1cdc
more fixes for DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17351
diff
changeset
|
115 long spinD1; |
d044ca4a1cdc
more fixes for DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17351
diff
changeset
|
116 long spinE; |
d044ca4a1cdc
more fixes for DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17351
diff
changeset
|
117 |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
118 try (DebugCloseable d1 = timerD.start()) { |
17357
d044ca4a1cdc
more fixes for DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17351
diff
changeset
|
119 spinD1 = spin(50); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
120 try (DebugCloseable e1 = timerE.start()) { |
17357
d044ca4a1cdc
more fixes for DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17351
diff
changeset
|
121 spinE = spin(50); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
122 try (DebugCloseable d2 = timerD.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
123 spin(50); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
124 try (DebugCloseable d3 = timerD.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
125 spin(50); |
17174
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
126 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
127 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
128 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
129 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
130 |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
131 Assert.assertTrue(timerE.getCurrentValue() < timerD.getCurrentValue()); |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
132 if (timerD.getFlat() != null && timerE.getFlat() != null) { |
17357
d044ca4a1cdc
more fixes for DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17351
diff
changeset
|
133 assertTrue(spinE >= spinD1 || timerE.getFlat().getCurrentValue() < timerD.getFlat().getCurrentValue()); |
17174
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
134 assertEquals(timerD.getFlat().getCurrentValue(), timerD.getCurrentValue() - timerE.getFlat().getCurrentValue(), 10D); |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
135 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
137 } |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
138 } |