Mercurial > hg > graal-compiler
annotate graal/com.oracle.jvmci.debug.test/src/com/oracle/jvmci/debug/test/DebugTimerTest.java @ 21652:5f3dda39d205
Truffle: add DynamicObject#containsKey, make flags parameter optional, minor simplifications
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Mon, 01 Jun 2015 12:55:56 +0200 |
parents | f5b549811bac |
children |
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 public class DebugTimerTest { |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
35 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
|
36 |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
37 /** |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
38 * 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
|
39 * that timers for the current thread keep ticking over. |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
40 * |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
41 * @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
|
42 * {@code ms} |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
43 */ |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
44 private static long spin(long ms) { |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
45 long start = threadMXBean.getCurrentThreadCpuTime(); |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
46 do { |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
47 long durationMS = (threadMXBean.getCurrentThreadCpuTime() - start) / 1000; |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
48 if (durationMS >= ms) { |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
49 return durationMS; |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
50 } |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
51 } while (true); |
17350
95663a6385cf
DebugTimerTest: ignore on windows for now
Bernhard Urban <bernhard.urban@jku.at>
parents:
17174
diff
changeset
|
52 } |
95663a6385cf
DebugTimerTest: ignore on windows for now
Bernhard Urban <bernhard.urban@jku.at>
parents:
17174
diff
changeset
|
53 |
17174
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 @Test |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 public void test1() { |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 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
|
57 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
|
58 |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 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
|
60 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
|
61 |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
62 long spinA; |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
63 long spinB; |
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
64 |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
65 try (DebugCloseable a1 = timerA.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
66 spinA = spin(50); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
67 try (DebugCloseable b1 = timerB.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
68 spinB = spin(50); |
17174
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 } |
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 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
|
73 if (timerA.getFlat() != null && timerB.getFlat() != null) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
74 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
|
75 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
|
76 } |
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 @Test |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 public void test2() { |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 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
|
83 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
|
84 DebugTimer timerC = Debug.timer("TimerC"); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
85 try (DebugCloseable c1 = timerC.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
86 spin(50); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
87 try (DebugCloseable c2 = timerC.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
88 spin(50); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
89 try (DebugCloseable c3 = timerC.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
90 spin(50); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
91 try (DebugCloseable c4 = timerC.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
92 spin(50); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
93 try (DebugCloseable c5 = timerC.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
94 spin(50); |
17174
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 } |
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 if (timerC.getFlat() != null) { |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
101 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
|
102 } |
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 @Test |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
107 public void test3() { |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
108 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
|
109 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
|
110 |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
111 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
|
112 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
|
113 |
17357
d044ca4a1cdc
more fixes for DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17351
diff
changeset
|
114 long spinD1; |
d044ca4a1cdc
more fixes for DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17351
diff
changeset
|
115 long spinE; |
d044ca4a1cdc
more fixes for DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17351
diff
changeset
|
116 |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
117 try (DebugCloseable d1 = timerD.start()) { |
17357
d044ca4a1cdc
more fixes for DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17351
diff
changeset
|
118 spinD1 = spin(50); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
119 try (DebugCloseable e1 = timerE.start()) { |
17357
d044ca4a1cdc
more fixes for DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17351
diff
changeset
|
120 spinE = spin(50); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
121 try (DebugCloseable d2 = timerD.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
122 spin(50); |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17357
diff
changeset
|
123 try (DebugCloseable d3 = timerD.start()) { |
17351
ea7b8c7a6e5c
fixed reliability of DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17350
diff
changeset
|
124 spin(50); |
17174
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
125 } |
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 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
|
131 if (timerD.getFlat() != null && timerE.getFlat() != null) { |
17357
d044ca4a1cdc
more fixes for DebugTimerTest
Doug Simon <doug.simon@oracle.com>
parents:
17351
diff
changeset
|
132 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
|
133 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
|
134 } |
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 } |