1 /* |
1 /* |
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
21 * questions. |
21 * questions. |
22 * |
22 * |
23 */ |
23 */ |
24 |
24 |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
|
26 #include "logging/log.hpp" |
26 #include "oops/oop.inline.hpp" |
27 #include "oops/oop.inline.hpp" |
27 #include "runtime/timer.hpp" |
28 #include "runtime/timer.hpp" |
28 #include "utilities/ostream.hpp" |
29 #include "utilities/ostream.hpp" |
29 |
30 |
30 double TimeHelper::counter_to_seconds(jlong counter) { |
31 double TimeHelper::counter_to_seconds(jlong counter) { |
112 assert(is_updated(), "must not be clear"); |
113 assert(is_updated(), "must not be clear"); |
113 return os::elapsed_counter() - _counter; |
114 return os::elapsed_counter() - _counter; |
114 } |
115 } |
115 |
116 |
116 TraceTime::TraceTime(const char* title, |
117 TraceTime::TraceTime(const char* title, |
117 bool doit) { |
118 bool doit, |
|
119 LogTagType tag) { |
118 _active = doit; |
120 _active = doit; |
119 _verbose = true; |
121 _verbose = true; |
|
122 _tag = tag; |
|
123 _title = title; |
120 |
124 |
121 if (_active) { |
125 if (_active) { |
122 _accum = NULL; |
126 _accum = NULL; |
123 tty->print("[%s", title); |
|
124 tty->flush(); |
|
125 _t.start(); |
127 _t.start(); |
126 } |
128 } |
127 } |
129 } |
128 |
130 |
129 TraceTime::TraceTime(const char* title, |
131 TraceTime::TraceTime(const char* title, |
130 elapsedTimer* accumulator, |
132 elapsedTimer* accumulator, |
131 bool doit, |
133 bool doit, |
132 bool verbose) { |
134 bool verbose, |
133 _active = doit; |
135 LogTagType tag) { |
134 _verbose = verbose; |
136 _active = doit; |
135 if (_active) { |
137 _verbose = verbose; |
136 if (_verbose) { |
138 _tag = tag; |
137 tty->print("[%s", title); |
139 _title = title; |
138 tty->flush(); |
140 |
139 } |
141 if (_active) { |
140 _accum = accumulator; |
142 _accum = accumulator; |
141 _t.start(); |
143 _t.start(); |
142 } |
144 } |
143 } |
145 } |
144 |
146 |
145 TraceTime::~TraceTime() { |
147 TraceTime::~TraceTime() { |
146 if (_active) { |
148 if (_active) { |
147 _t.stop(); |
149 _t.stop(); |
148 if (_accum!=NULL) _accum->add(_t); |
150 if (_accum!=NULL) _accum->add(_t); |
149 if (_verbose) { |
151 if (_verbose) { |
150 tty->print_cr(", %3.7f secs]", _t.seconds()); |
152 switch (_tag) { |
151 tty->flush(); |
153 case LogTag::_startuptime : |
|
154 log_info(startuptime)("%s, %3.7f secs", _title, _t.seconds()); |
|
155 break; |
|
156 case LogTag::__NO_TAG : |
|
157 default : |
|
158 tty->print_cr("[%s, %3.7f secs]", _title, _t.seconds()); |
|
159 tty->flush(); |
|
160 } |
152 } |
161 } |
153 } |
162 } |
154 } |
163 } |
155 |
164 |
156 TraceCPUTime::TraceCPUTime(bool doit, |
165 TraceCPUTime::TraceCPUTime(bool doit, |