Mercurial > hg > truffle
annotate src/share/vm/utilities/histogram.hpp @ 17352:ea7b8c7a6e5c
fixed reliability of DebugTimerTest
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 06 Oct 2014 17:32:55 +0200 |
parents | 4ca6dc0799b6 |
children | 52b4284cb496 |
rev | line source |
---|---|
0 | 1 /* |
6842
b9a9ed0f8eeb
7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents:
6197
diff
changeset
|
2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_UTILITIES_HISTOGRAM_HPP |
26 #define SHARE_VM_UTILITIES_HISTOGRAM_HPP | |
27 | |
28 #include "memory/allocation.hpp" | |
29 #include "runtime/os.hpp" | |
30 #include "utilities/growableArray.hpp" | |
31 #ifdef TARGET_OS_FAMILY_linux | |
32 # include "os_linux.inline.hpp" | |
33 #endif | |
34 #ifdef TARGET_OS_FAMILY_solaris | |
35 # include "os_solaris.inline.hpp" | |
36 #endif | |
37 #ifdef TARGET_OS_FAMILY_windows | |
38 # include "os_windows.inline.hpp" | |
39 #endif | |
3960 | 40 #ifdef TARGET_OS_FAMILY_bsd |
41 # include "os_bsd.inline.hpp" | |
42 #endif | |
1972 | 43 |
0 | 44 // This class provides a framework for collecting various statistics. |
45 // The current implementation is oriented towards counting invocations | |
46 // of various types, but that can be easily changed. | |
47 // | |
48 // To use it, you need to declare a Histogram*, and a subtype of | |
49 // HistogramElement: | |
50 // | |
51 // HistogramElement* MyHistogram; | |
52 // | |
53 // class MyHistogramElement : public HistogramElement { | |
54 // public: | |
55 // MyHistogramElement(char* name); | |
56 // }; | |
57 // | |
58 // MyHistogramElement::MyHistogramElement(char* elementName) { | |
59 // _name = elementName; | |
60 // | |
61 // if(MyHistogram == NULL) | |
62 // MyHistogram = new Histogram("My Call Counts",100); | |
63 // | |
64 // MyHistogram->add_element(this); | |
65 // } | |
66 // | |
67 // #define MyCountWrapper(arg) static MyHistogramElement* e = new MyHistogramElement(arg); e->increment_count() | |
68 // | |
69 // This gives you a simple way to count invocations of specfic functions: | |
70 // | |
71 // void a_function_that_is_being_counted() { | |
72 // MyCountWrapper("FunctionName"); | |
73 // ... | |
74 // } | |
75 // | |
76 // To print the results, invoke print() on your Histogram*. | |
77 | |
78 #ifdef ASSERT | |
79 | |
6197 | 80 class HistogramElement : public CHeapObj<mtInternal> { |
0 | 81 protected: |
82 jint _count; | |
83 const char* _name; | |
84 | |
85 public: | |
86 HistogramElement(); | |
87 virtual int count(); | |
88 virtual const char* name(); | |
89 virtual void increment_count(); | |
90 void print_on(outputStream* st) const; | |
91 virtual int compare(HistogramElement* e1,HistogramElement* e2); | |
92 }; | |
93 | |
6197 | 94 class Histogram : public CHeapObj<mtInternal> { |
0 | 95 protected: |
96 GrowableArray<HistogramElement*>* _elements; | |
97 GrowableArray<HistogramElement*>* elements() { return _elements; } | |
98 const char* _title; | |
99 const char* title() { return _title; } | |
100 static int sort_helper(HistogramElement** e1,HistogramElement** e2); | |
101 virtual void print_header(outputStream* st); | |
102 virtual void print_elements(outputStream* st); | |
103 | |
104 public: | |
105 Histogram(const char* title,int estimatedSize); | |
106 virtual void add_element(HistogramElement* element); | |
107 void print_on(outputStream* st) const; | |
108 }; | |
109 | |
110 #endif | |
1972 | 111 |
112 #endif // SHARE_VM_UTILITIES_HISTOGRAM_HPP |