Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/utilities/histogram.hpp
32285 views
1
/*
2
* Copyright (c) 1998, 2012, 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
#ifdef TARGET_OS_FAMILY_aix
41
# include "os_aix.inline.hpp"
42
#endif
43
#ifdef TARGET_OS_FAMILY_bsd
44
# include "os_bsd.inline.hpp"
45
#endif
46
47
// This class provides a framework for collecting various statistics.
48
// The current implementation is oriented towards counting invocations
49
// of various types, but that can be easily changed.
50
//
51
// To use it, you need to declare a Histogram*, and a subtype of
52
// HistogramElement:
53
//
54
// HistogramElement* MyHistogram;
55
//
56
// class MyHistogramElement : public HistogramElement {
57
// public:
58
// MyHistogramElement(char* name);
59
// };
60
//
61
// MyHistogramElement::MyHistogramElement(char* elementName) {
62
// _name = elementName;
63
//
64
// if(MyHistogram == NULL)
65
// MyHistogram = new Histogram("My Call Counts",100);
66
//
67
// MyHistogram->add_element(this);
68
// }
69
//
70
// #define MyCountWrapper(arg) static MyHistogramElement* e = new MyHistogramElement(arg); e->increment_count()
71
//
72
// This gives you a simple way to count invocations of specfic functions:
73
//
74
// void a_function_that_is_being_counted() {
75
// MyCountWrapper("FunctionName");
76
// ...
77
// }
78
//
79
// To print the results, invoke print() on your Histogram*.
80
81
#ifdef ASSERT
82
83
class HistogramElement : public CHeapObj<mtInternal> {
84
protected:
85
jint _count;
86
const char* _name;
87
88
public:
89
HistogramElement();
90
virtual int count();
91
virtual const char* name();
92
virtual void increment_count();
93
void print_on(outputStream* st) const;
94
virtual int compare(HistogramElement* e1,HistogramElement* e2);
95
};
96
97
class Histogram : public CHeapObj<mtInternal> {
98
protected:
99
GrowableArray<HistogramElement*>* _elements;
100
GrowableArray<HistogramElement*>* elements() { return _elements; }
101
const char* _title;
102
const char* title() { return _title; }
103
static int sort_helper(HistogramElement** e1,HistogramElement** e2);
104
virtual void print_header(outputStream* st);
105
virtual void print_elements(outputStream* st);
106
107
public:
108
Histogram(const char* title,int estimatedSize);
109
virtual void add_element(HistogramElement* element);
110
void print_on(outputStream* st) const;
111
};
112
113
#endif
114
115
#endif // SHARE_VM_UTILITIES_HISTOGRAM_HPP
116
117