Mercurial > hg > graal-compiler
annotate graal/com.oracle.jvmci.debug/src/com/oracle/jvmci/debug/DebugTimer.java @ 21709:3c17c0c41a6b
moved com.oracle.asm.**.test to JVMCI namespace (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 03 Jun 2015 18:33:23 +0200 |
parents | b1530a6cce8c |
children |
rev | line source |
---|---|
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
719ac1d92a52
More work on debug framework.
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:
19693
diff
changeset
|
23 package com.oracle.jvmci.debug; |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
12778
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
11562
diff
changeset
|
25 import java.util.concurrent.*; |
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
11562
diff
changeset
|
26 |
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
|
27 /** |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
28 * A timer for some activity of interest. A timer should be deployed using the try-with-resources |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
29 * pattern: |
15581
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
12778
diff
changeset
|
30 * |
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
|
31 * <pre> |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
32 * try (TimerCloseable a = timer.start()) { |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
33 * // the code to time |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
34 * } |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
35 * </pre> |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
36 */ |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 public interface DebugTimer { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
38 |
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
|
39 /** |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
40 * Starts this timer if timing is {@linkplain Debug#isTimeEnabled() enabled} or this is an |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
41 * {@linkplain #isConditional() unconditional} timer. |
15581
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
12778
diff
changeset
|
42 * |
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
|
43 * @return an object that must be closed once the activity has completed to add the elapsed time |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
44 * since this call to the total for this timer |
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 */ |
19693
fa75218e3942
Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
17174
diff
changeset
|
46 DebugCloseable start(); |
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
|
47 |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
48 /** |
15581
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
12778
diff
changeset
|
49 * Sets a flag determining if this timer is only enabled if timing is |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
12778
diff
changeset
|
50 * {@link Debug#isTimeEnabled() enabled}. |
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
|
51 */ |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
52 void setConditional(boolean flag); |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
53 |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
54 /** |
15581
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
12778
diff
changeset
|
55 * Determines if this timer is only enabled if timing is {@link Debug#isTimeEnabled() enabled}. |
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
|
56 */ |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
57 boolean isConditional(); |
12778
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
11562
diff
changeset
|
58 |
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
11562
diff
changeset
|
59 /** |
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
11562
diff
changeset
|
60 * Gets the current value of this timer. |
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
11562
diff
changeset
|
61 */ |
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
11562
diff
changeset
|
62 long getCurrentValue(); |
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
11562
diff
changeset
|
63 |
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
11562
diff
changeset
|
64 /** |
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
11562
diff
changeset
|
65 * Gets the time unit of this timer. |
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
11562
diff
changeset
|
66 */ |
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
11562
diff
changeset
|
67 TimeUnit getTimeUnit(); |
17174
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
15581
diff
changeset
|
68 |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
15581
diff
changeset
|
69 /** |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
15581
diff
changeset
|
70 * Gets the timer recording the amount time spent within a timed scope minus the time spent in |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
15581
diff
changeset
|
71 * any nested timed scopes. |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
15581
diff
changeset
|
72 * |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
15581
diff
changeset
|
73 * @return null if this timer does not support flat timing |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
15581
diff
changeset
|
74 */ |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
15581
diff
changeset
|
75 default DebugTimer getFlat() { |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
15581
diff
changeset
|
76 return null; |
2cb007e99ed0
added support for getting the flat time from a DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
15581
diff
changeset
|
77 } |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 } |