1 /*
2 * Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved.
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 // This class provides a framework for collecting various statistics.
26 // The current implementation is oriented towards counting invocations
27 // of various types, but that can be easily changed.
28 //
29 // To use it, you need to declare a Histogram*, and a subtype of
30 // HistogramElement:
31 //
32 // HistogramElement* MyHistogram;
33 //
34 // class MyHistogramElement : public HistogramElement {
35 // public:
36 // MyHistogramElement(char* name);
37 // };
38 //
39 // MyHistogramElement::MyHistogramElement(char* elementName) {
40 // _name = elementName;
41 //
42 // if(MyHistogram == NULL)
43 // MyHistogram = new Histogram("My Call Counts",100);
44 //
72 virtual int compare(HistogramElement* e1,HistogramElement* e2);
73 };
74
75 class Histogram : public CHeapObj {
76 protected:
77 GrowableArray<HistogramElement*>* _elements;
78 GrowableArray<HistogramElement*>* elements() { return _elements; }
79 const char* _title;
80 const char* title() { return _title; }
81 static int sort_helper(HistogramElement** e1,HistogramElement** e2);
82 virtual void print_header(outputStream* st);
83 virtual void print_elements(outputStream* st);
84
85 public:
86 Histogram(const char* title,int estimatedSize);
87 virtual void add_element(HistogramElement* element);
88 void print_on(outputStream* st) const;
89 };
90
91 #endif
|
1 /*
2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
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
40
41 // This class provides a framework for collecting various statistics.
42 // The current implementation is oriented towards counting invocations
43 // of various types, but that can be easily changed.
44 //
45 // To use it, you need to declare a Histogram*, and a subtype of
46 // HistogramElement:
47 //
48 // HistogramElement* MyHistogram;
49 //
50 // class MyHistogramElement : public HistogramElement {
51 // public:
52 // MyHistogramElement(char* name);
53 // };
54 //
55 // MyHistogramElement::MyHistogramElement(char* elementName) {
56 // _name = elementName;
57 //
58 // if(MyHistogram == NULL)
59 // MyHistogram = new Histogram("My Call Counts",100);
60 //
88 virtual int compare(HistogramElement* e1,HistogramElement* e2);
89 };
90
91 class Histogram : public CHeapObj {
92 protected:
93 GrowableArray<HistogramElement*>* _elements;
94 GrowableArray<HistogramElement*>* elements() { return _elements; }
95 const char* _title;
96 const char* title() { return _title; }
97 static int sort_helper(HistogramElement** e1,HistogramElement** e2);
98 virtual void print_header(outputStream* st);
99 virtual void print_elements(outputStream* st);
100
101 public:
102 Histogram(const char* title,int estimatedSize);
103 virtual void add_element(HistogramElement* element);
104 void print_on(outputStream* st) const;
105 };
106
107 #endif
108
109 #endif // SHARE_VM_UTILITIES_HISTOGRAM_HPP
|