Mercurial > hg > truffle
annotate graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/TimerImpl.java @ 11628:febd01be55e0
moved 'conditional' field and related methods down in DebugValue
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 13 Sep 2013 15:20:53 +0200 |
parents | 0d10c6717edf |
children | a0da0bff042e |
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 */ |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
23 package com.oracle.graal.debug.internal; |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
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
|
25 import java.lang.management.*; |
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
|
26 |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
27 import com.oracle.graal.debug.*; |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 |
4356
249752adcb8d
Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
29 public final class TimerImpl extends DebugValue implements DebugTimer { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7247
diff
changeset
|
30 |
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
|
31 private static final ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean(); |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 |
4406
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
33 public static final TimerCloseable VOID_CLOSEABLE = new TimerCloseable() { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7247
diff
changeset
|
34 |
4406
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
35 @Override |
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
36 public void close() { |
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
37 } |
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
38 }; |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 |
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
|
40 /** |
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
|
41 * 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
|
42 */ |
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
|
43 private static ThreadLocal<AbstractTimer> currentTimer = new ThreadLocal<>(); |
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
|
44 |
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
|
45 public TimerImpl(String name, boolean conditional) { |
11628
febd01be55e0
moved 'conditional' field and related methods down in DebugValue
Doug Simon <doug.simon@oracle.com>
parents:
11617
diff
changeset
|
46 super(name, conditional); |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 @Override |
4406
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
50 public TimerCloseable start() { |
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
51 if (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
|
52 long startTime; |
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
|
53 if (threadMXBean.isCurrentThreadCpuTimeSupported()) { |
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
|
54 startTime = 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
|
55 } else { |
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
|
56 startTime = 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
|
57 } |
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
|
58 |
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
|
59 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
|
60 if (threadMXBean.isCurrentThreadCpuTimeSupported()) { |
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
|
61 result = new CpuTimeTimer(startTime); |
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
|
62 } else { |
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
|
63 result = new SystemNanosTimer(startTime); |
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
|
64 } |
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
|
65 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
|
66 return result; |
4406
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
67 } else { |
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
68 return VOID_CLOSEABLE; |
961895157a38
Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
69 } |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 } |
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
|
71 |
11628
febd01be55e0
moved 'conditional' field and related methods down in DebugValue
Doug Simon <doug.simon@oracle.com>
parents:
11617
diff
changeset
|
72 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
|
73 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
|
74 } |
febd01be55e0
moved 'conditional' field and related methods down in DebugValue
Doug Simon <doug.simon@oracle.com>
parents:
11617
diff
changeset
|
75 |
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
|
76 @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
|
77 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
|
78 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
|
79 } |
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
|
80 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7247
diff
changeset
|
81 private abstract class AbstractTimer implements TimerCloseable { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7247
diff
changeset
|
82 |
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
|
83 private final AbstractTimer 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
|
84 private final long startTime; |
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
|
85 private long nestedTimeToSubtract; |
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
|
86 |
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
|
87 private AbstractTimer(long startTime) { |
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
|
88 this.parent = currentTimer.get(); |
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
|
89 this.startTime = startTime; |
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
|
90 } |
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
|
91 |
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
|
92 @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
|
93 public void 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
|
94 long endTime = currentTime(); |
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
|
95 long timeSpan = endTime - startTime; |
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
|
96 if (parent != null) { |
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
|
97 parent.nestedTimeToSubtract += timeSpan; |
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
|
98 } |
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
|
99 currentTimer.set(parent); |
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
|
100 long flatTime = timeSpan - nestedTimeToSubtract; |
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
|
101 TimerImpl.this.addToCurrentValue(flatTime); |
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
|
102 } |
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
|
103 |
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
|
104 protected abstract long currentTime(); |
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 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
|
108 |
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
|
109 public SystemNanosTimer(long startTime) { |
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 super(startTime); |
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 @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
|
114 protected long currentTime() { |
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
|
115 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
|
116 } |
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
|
117 } |
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 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
|
120 |
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
|
121 public CpuTimeTimer(long startTime) { |
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
|
122 super(startTime); |
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
|
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 @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
|
126 protected long currentTime() { |
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
|
127 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
|
128 } |
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
|
129 } |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 } |