1 /*
2 * Copyright (c) 2012, 2019, 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 *
26 #define SHARE_GC_SHARED_GCTRACETIME_HPP
27
28 #include "logging/log.hpp"
29 #include "logging/logHandle.hpp"
30 #include "logging/logStream.hpp"
31 #include "memory/allocation.hpp"
32 #include "utilities/ticks.hpp"
33
34 class GCTraceCPUTime : public StackObj {
35 bool _active; // true if times will be measured and printed
36 double _starting_user_time; // user time at start of measurement
37 double _starting_system_time; // system time at start of measurement
38 double _starting_real_time; // real time at start of measurement
39 public:
40 GCTraceCPUTime();
41 ~GCTraceCPUTime();
42 };
43
44 class GCTimer;
45
46 class GCTraceTimeImpl : public StackObj {
47 private:
48 LogTargetHandle _out_start;
49 LogTargetHandle _out_stop;
50 bool _enabled;
51 Ticks _start_ticks;
52 const char* _title;
53 GCCause::Cause _gc_cause;
54 GCTimer* _timer;
55 size_t _heap_usage_before;
56
57 void log_start(jlong start_counter);
58 void log_stop(jlong start_counter, jlong stop_counter);
59 void time_stamp(Ticks& ticks);
60
61 public:
62 GCTraceTimeImpl(LogTargetHandle out_start, LogTargetHandle out_end, const char* title, GCTimer* timer = NULL, GCCause::Cause gc_cause = GCCause::_no_gc, bool log_heap_usage = false);
63 ~GCTraceTimeImpl();
64 };
65
66 template <LogLevelType Level, LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag>
67 class GCTraceTimeImplWrapper : public StackObj {
68 GCTraceTimeImpl _impl;
69 public:
70 GCTraceTimeImplWrapper(const char* title, GCTimer* timer = NULL, GCCause::Cause gc_cause = GCCause::_no_gc, bool log_heap_usage = false);
71 ~GCTraceTimeImplWrapper();
72 };
73
74 // Similar to GCTraceTimeImpl but is intended for concurrent phase logging,
75 // which is a bit simpler and should always print the start line, i.e. not add the "start" tag.
76 template <LogLevelType Level, LogTagType T0, LogTagType T1 = LogTag::__NO_TAG, LogTagType T2 = LogTag::__NO_TAG, LogTagType T3 = LogTag::__NO_TAG,
77 LogTagType T4 = LogTag::__NO_TAG, LogTagType GuardTag = LogTag::__NO_TAG>
78 class GCTraceConcTimeImpl : public StackObj {
79 private:
80 bool _enabled;
81 jlong _start_time;
82 const char* _title;
83 public:
84 GCTraceConcTimeImpl(const char* title);
85 ~GCTraceConcTimeImpl();
86 jlong start_time() { return _start_time; }
87 };
88
89 #endif // SHARE_GC_SHARED_GCTRACETIME_HPP
|
1 /*
2 * Copyright (c) 2012, 2020, 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 *
26 #define SHARE_GC_SHARED_GCTRACETIME_HPP
27
28 #include "logging/log.hpp"
29 #include "logging/logHandle.hpp"
30 #include "logging/logStream.hpp"
31 #include "memory/allocation.hpp"
32 #include "utilities/ticks.hpp"
33
34 class GCTraceCPUTime : public StackObj {
35 bool _active; // true if times will be measured and printed
36 double _starting_user_time; // user time at start of measurement
37 double _starting_system_time; // system time at start of measurement
38 double _starting_real_time; // real time at start of measurement
39 public:
40 GCTraceCPUTime();
41 ~GCTraceCPUTime();
42 };
43
44 class GCTimer;
45
46 template <typename Handle1, typename Handle2>
47 class GCTraceTimeImpl : public StackObj {
48 private:
49 Handle1 _out_start;
50 Handle2 _out_stop;
51 bool _enabled;
52 Ticks _start_ticks;
53 const char* _title;
54 GCCause::Cause _gc_cause;
55 GCTimer* _timer;
56 size_t _heap_usage_before;
57
58 void log_start(jlong start_counter);
59 void log_stop(jlong start_counter, jlong stop_counter);
60 void time_stamp(Ticks& ticks);
61
62 public:
63 GCTraceTimeImpl(Handle1 out_start, Handle2 out_end, const char* title, GCTimer* timer = NULL, GCCause::Cause gc_cause = GCCause::_no_gc, bool log_heap_usage = false);
64 ~GCTraceTimeImpl();
65 };
66
67 template <LogLevelType Level, LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag>
68 class GCTraceTimeImplWrapper : public StackObj {
69 typedef GCTraceTimeImpl<LogTargetHandle, LogTargetHandle> handle_t;
70 const handle_t _impl;
71 public:
72 GCTraceTimeImplWrapper(const char* title, GCTimer* timer = NULL, GCCause::Cause gc_cause = GCCause::_no_gc, bool log_heap_usage = false);
73 };
74
75 template <LogLevelType Level, LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag>
76 class GCAsyncTraceTimeImplWrapper : public StackObj {
77 typedef GCTraceTimeImpl<AsyncLogTargetHandle, AsyncLogTargetHandle> handle_t;
78 const handle_t _impl;
79 public:
80 GCAsyncTraceTimeImplWrapper(const char* title, GCTimer* timer = NULL, GCCause::Cause gc_cause = GCCause::_no_gc, bool log_heap_usage = false);
81 };
82 // Similar to GCTraceTimeImpl but is intended for concurrent phase logging,
83 // which is a bit simpler and should always print the start line, i.e. not add the "start" tag.
84 template <LogLevelType Level, LogTagType T0, LogTagType T1 = LogTag::__NO_TAG, LogTagType T2 = LogTag::__NO_TAG, LogTagType T3 = LogTag::__NO_TAG,
85 LogTagType T4 = LogTag::__NO_TAG, LogTagType GuardTag = LogTag::__NO_TAG>
86 class GCTraceConcTimeImpl : public StackObj {
87 private:
88 bool _enabled;
89 jlong _start_time;
90 const char* _title;
91 public:
92 GCTraceConcTimeImpl(const char* title);
93 ~GCTraceConcTimeImpl();
94 jlong start_time() { return _start_time; }
95 };
96
97 #endif // SHARE_GC_SHARED_GCTRACETIME_HPP
|