annotate graal/com.oracle.jvmci.debug/src/com/oracle/jvmci/debug/internal/TimerImpl.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/src/com/oracle/graal/debug/internal/TimerImpl.java@fa75218e3942
children f5b549811bac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@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: 19686
diff changeset
23 package com.oracle.jvmci.debug.internal;
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
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: 19686
diff changeset
25 import static com.oracle.jvmci.debug.DebugCloseable.*;
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
26
7247
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
27 import java.lang.management.*;
12778
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 11630
diff changeset
28 import java.util.concurrent.*;
7247
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
29
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: 19686
diff changeset
30 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: 19686
diff changeset
31
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
33 public final class TimerImpl extends AccumulatedDebugValue implements DebugTimer {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7247
diff changeset
34
7247
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
35 private static final ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36
11617
0d10c6717edf fixed TimerImpl to account for (i.e., deduct) all nested timers, not just the most recent one
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
37 /**
0d10c6717edf fixed TimerImpl to account for (i.e., deduct) all nested timers, not just the most recent one
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
38 * Records the most recent active timer.
0d10c6717edf fixed TimerImpl to account for (i.e., deduct) all nested timers, not just the most recent one
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
39 */
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
40 private static final ThreadLocal<CloseableCounterImpl> currentTimer = new ThreadLocal<>();
17174
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
41
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
42 static class FlatTimer extends DebugValue implements DebugTimer {
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
43 private TimerImpl accm;
17174
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
44
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
45 public FlatTimer(String name, boolean conditional) {
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
46 super(name + "_Flat", conditional);
17174
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
47 }
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
48
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
49 @Override
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
50 public String toString(long value) {
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
51 return valueToString(value);
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
52 }
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
53
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
54 public TimeUnit getTimeUnit() {
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
55 return accm.getTimeUnit();
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
56 }
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
57
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
58 public DebugCloseable start() {
17174
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
59 return accm.start();
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
60 }
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
61 }
11630
103e4438bb19 added support for accumulative times to TimerImpl
Doug Simon <doug.simon@oracle.com>
parents: 11629
diff changeset
62
11562
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
63 public TimerImpl(String name, boolean conditional) {
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
64 super(name, conditional, new FlatTimer(name, conditional));
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
65 ((FlatTimer) flat).accm = this;
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66 }
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 @Override
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
69 public DebugCloseable start() {
11629
a0da0bff042e made TimerImpl respect conditional flag (GRAAL-470)
Doug Simon <doug.simon@oracle.com>
parents: 11628
diff changeset
70 if (!isConditional() || Debug.isTimeEnabled()) {
7247
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
71 AbstractTimer result;
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
72 if (threadMXBean.isCurrentThreadCpuTimeSupported()) {
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
73 result = new CpuTimeTimer(this);
7247
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
74 } else {
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
75 result = new SystemNanosTimer(this);
7247
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
76 }
11617
0d10c6717edf fixed TimerImpl to account for (i.e., deduct) all nested timers, not just the most recent one
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
77 currentTimer.set(result);
5134
4eb9895d9afe Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
78 return result;
4406
961895157a38 Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
79 } else {
961895157a38 Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
80 return VOID_CLOSEABLE;
961895157a38 Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
81 }
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 }
5134
4eb9895d9afe Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
83
11628
febd01be55e0 moved 'conditional' field and related methods down in DebugValue
Doug Simon <doug.simon@oracle.com>
parents: 11617
diff changeset
84 public static String valueToString(long value) {
febd01be55e0 moved 'conditional' field and related methods down in DebugValue
Doug Simon <doug.simon@oracle.com>
parents: 11617
diff changeset
85 return String.format("%d.%d ms", value / 1000000, (value / 100000) % 10);
febd01be55e0 moved 'conditional' field and related methods down in DebugValue
Doug Simon <doug.simon@oracle.com>
parents: 11617
diff changeset
86 }
febd01be55e0 moved 'conditional' field and related methods down in DebugValue
Doug Simon <doug.simon@oracle.com>
parents: 11617
diff changeset
87
17174
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
88 public DebugTimer getFlat() {
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
89 return (FlatTimer) flat;
17174
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
90 }
2cb007e99ed0 added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 14017
diff changeset
91
5134
4eb9895d9afe Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
92 @Override
4eb9895d9afe Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
93 public String toString(long value) {
11628
febd01be55e0 moved 'conditional' field and related methods down in DebugValue
Doug Simon <doug.simon@oracle.com>
parents: 11617
diff changeset
94 return valueToString(value);
5134
4eb9895d9afe Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
95 }
7247
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
96
12778
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 11630
diff changeset
97 public TimeUnit getTimeUnit() {
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 11630
diff changeset
98 return TimeUnit.NANOSECONDS;
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 11630
diff changeset
99 }
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 11630
diff changeset
100
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
101 private abstract static class AbstractTimer extends CloseableCounterImpl implements DebugCloseable {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7247
diff changeset
102
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
103 private AbstractTimer(AccumulatedDebugValue counter) {
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
104 super(currentTimer.get(), counter);
7247
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
105 }
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
106
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
107 @Override
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
108 public void close() {
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
109 super.close();
11617
0d10c6717edf fixed TimerImpl to account for (i.e., deduct) all nested timers, not just the most recent one
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
110 currentTimer.set(parent);
7247
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
111 }
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
112 }
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
113
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
114 private final class SystemNanosTimer extends AbstractTimer {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7247
diff changeset
115
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
116 public SystemNanosTimer(TimerImpl timer) {
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
117 super(timer);
7247
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
118 }
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
119
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
120 @Override
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
121 protected long getCounterValue() {
7247
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
122 return System.nanoTime();
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
123 }
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
124 }
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
125
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
126 private final class CpuTimeTimer extends AbstractTimer {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7247
diff changeset
127
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
128 public CpuTimeTimer(TimerImpl timer) {
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
129 super(timer);
7247
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
130 }
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
131
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
132 @Override
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18163
diff changeset
133 protected long getCounterValue() {
7247
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
134 return threadMXBean.getCurrentThreadCpuTime();
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
135 }
1706be855f0e Use ThreadMXBean to get CPU time instead of Wallclock time for Timers if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5134
diff changeset
136 }
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
137 }