1 /*
2 * Copyright (c) 1997, 2014, 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 #include "precompiled.hpp"
26 #include "oops/oop.inline.hpp"
27 #include "runtime/timer.hpp"
28 #include "utilities/ostream.hpp"
29 #ifdef INCLUDE_ALL_GCS
30 #include "gc_implementation/g1/g1GCPhaseTimes.hpp"
31 #endif
32
33 double TimeHelper::counter_to_seconds(jlong counter) {
34 double count = (double) counter;
35 double freq = (double) os::elapsed_frequency();
36 return counter/freq;
37 }
38
39 void elapsedTimer::add(elapsedTimer t) {
40 _counter += t._counter;
41 }
42
43 void elapsedTimer::start() {
44 if (!_active) {
45 _active = true;
46 _start_counter = os::elapsed_counter();
47 }
48 }
49
50 void elapsedTimer::stop() {
51 if (_active) {
126 tty->stamp(PrintGCTimeStamps);
127 tty->print("[%s", title);
128 tty->flush();
129 }
130 _accum = accumulator;
131 _t.start();
132 }
133 }
134
135 TraceTime::~TraceTime() {
136 if (_active) {
137 _t.stop();
138 if (_accum!=NULL) _accum->add(_t);
139 if (_verbose) {
140 tty->print_cr(", %3.7f secs]", _t.seconds());
141 tty->flush();
142 }
143 }
144 }
145
146 TrackPhaseTime::TrackPhaseTime(GCPhaseTimeTracker *data, uint phase) :
147 _data(data), _phase(phase) {
148 if (_data != NULL && _data->active()) {
149 _last = os::elapsed_counter();
150 }
151 }
152
153 TrackPhaseTime::~TrackPhaseTime() {
154 if (_data != NULL && _data->active()) {
155 double time = (double)(os::elapsed_counter() - _last) * 1000.0 / os::elapsed_frequency();
156 _data->set_value(_phase, time);
157 }
158 }
159
160 TraceCPUTime::TraceCPUTime(bool doit,
161 bool print_cr,
162 outputStream *logfile) :
163 _active(doit),
164 _print_cr(print_cr),
165 _starting_user_time(0.0),
166 _starting_system_time(0.0),
|
1 /*
2 * Copyright (c) 1997, 2015, 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 #include "precompiled.hpp"
26 #include "oops/oop.inline.hpp"
27 #include "runtime/timer.hpp"
28 #include "utilities/ostream.hpp"
29
30 double TimeHelper::counter_to_seconds(jlong counter) {
31 double count = (double) counter;
32 double freq = (double) os::elapsed_frequency();
33 return counter/freq;
34 }
35
36 void elapsedTimer::add(elapsedTimer t) {
37 _counter += t._counter;
38 }
39
40 void elapsedTimer::start() {
41 if (!_active) {
42 _active = true;
43 _start_counter = os::elapsed_counter();
44 }
45 }
46
47 void elapsedTimer::stop() {
48 if (_active) {
123 tty->stamp(PrintGCTimeStamps);
124 tty->print("[%s", title);
125 tty->flush();
126 }
127 _accum = accumulator;
128 _t.start();
129 }
130 }
131
132 TraceTime::~TraceTime() {
133 if (_active) {
134 _t.stop();
135 if (_accum!=NULL) _accum->add(_t);
136 if (_verbose) {
137 tty->print_cr(", %3.7f secs]", _t.seconds());
138 tty->flush();
139 }
140 }
141 }
142
143 TrackPhaseTime::TrackPhaseTime(PhaseTimeData *data, uint phase) :
144 _data(data), _phase(phase) {
145 if (_data != NULL && _data->active()) {
146 _last = os::elapsed_counter();
147 }
148 }
149
150 TrackPhaseTime::~TrackPhaseTime() {
151 if (_data != NULL && _data->active()) {
152 double time = (double)(os::elapsed_counter() - _last) * 1000.0 / os::elapsed_frequency();
153 _data->set_value(_phase, time);
154 }
155 }
156
157 TraceCPUTime::TraceCPUTime(bool doit,
158 bool print_cr,
159 outputStream *logfile) :
160 _active(doit),
161 _print_cr(print_cr),
162 _starting_user_time(0.0),
163 _starting_system_time(0.0),
|