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_GC_SHARED_GCTRACETIME_HPP 26 #define SHARE_VM_GC_SHARED_GCTRACETIME_HPP 27 28 #include "gc/shared/gcTrace.hpp" 29 #include "memory/allocation.hpp" 30 #include "prims/jni_md.h" 31 #include "utilities/ticks.hpp" 32 33 class GCTimer; 34 35 class GCTraceTimeImpl VALUE_OBJ_CLASS_SPEC { 36 const char* _title; 37 bool _doit; 38 bool _print_cr; 39 GCTimer* _timer; 40 Ticks _start_counter; 41 42 public: 43 GCTraceTimeImpl(const char* title, bool doit, bool print_cr, GCTimer* timer); 44 ~GCTraceTimeImpl(); 45 }; 46 47 class GCTraceTime : public StackObj { 48 GCTraceTimeImpl _gc_trace_time_impl; 49 50 public: 51 GCTraceTime(const char* title, bool doit, bool print_cr, GCTimer* timer) : 52 _gc_trace_time_impl(title, doit, print_cr, timer) {}; 53 }; 54 55 #endif // SHARE_VM_GC_SHARED_GCTRACETIME_HPP | 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_GC_SHARED_GCTRACETIME_HPP 26 #define SHARE_VM_GC_SHARED_GCTRACETIME_HPP 27 28 #include "logging/log.hpp" 29 #include "memory/allocation.hpp" 30 #include "utilities/ticks.hpp" 31 32 class GCTraceCPUTime : public StackObj { 33 bool _active; // true if times will be measured and printed 34 double _starting_user_time; // user time at start of measurement 35 double _starting_system_time; // system time at start of measurement 36 double _starting_real_time; // real time at start of measurement 37 public: 38 GCTraceCPUTime(); 39 ~GCTraceCPUTime(); 40 }; 41 42 class GCTimer; 43 44 template <LogLevelType Level, LogTagType T0, LogTagType T1 = LogTag::__NO_TAG, LogTagType T2 = LogTag::__NO_TAG, LogTagType T3 = LogTag::__NO_TAG, 45 LogTagType T4 = LogTag::__NO_TAG, LogTagType GuardTag = LogTag::__NO_TAG> 46 class GCTraceTimeImpl : public StackObj { 47 private: 48 bool _enabled; 49 Ticks _start_ticks; 50 const char* _title; 51 GCCause::Cause _gc_cause; 52 GCTimer* _timer; 53 size_t _heap_usage_before; 54 55 void log_start(jlong start_counter); 56 void log_stop(jlong start_counter, jlong stop_counter); 57 void time_stamp(Ticks& ticks); 58 59 public: 60 GCTraceTimeImpl(const char* title, GCTimer* timer = NULL, GCCause::Cause gc_cause = GCCause::_no_gc, bool log_heap_usage = false); 61 ~GCTraceTimeImpl(); 62 }; 63 64 // Similar to GCTraceTimeImpl but is intended for concurrent phase logging, 65 // which is a bit simpler and should always print the start line, i.e. not add the "start" tag. 66 template <LogLevelType Level, LogTagType T0, LogTagType T1 = LogTag::__NO_TAG, LogTagType T2 = LogTag::__NO_TAG, LogTagType T3 = LogTag::__NO_TAG, 67 LogTagType T4 = LogTag::__NO_TAG, LogTagType GuardTag = LogTag::__NO_TAG> 68 class GCTraceConcTimeImpl : public StackObj { 69 private: 70 bool _enabled; 71 jlong _start_time; 72 const char* _title; 73 public: 74 GCTraceConcTimeImpl(const char* title); 75 ~GCTraceConcTimeImpl(); 76 jlong start_time() { return _start_time; } 77 }; 78 79 #endif // SHARE_VM_GC_SHARED_GCTRACETIME_HPP |