< prev index next >

src/share/vm/runtime/timer.cpp

Print this page
rev 7854 : imported patch 8027962-per-phase-timing-measurements-for-strong-roots-processing
rev 7855 : [mq]: 8027962-bengt-suggestions
   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  *


 120   _verbose = verbose;
 121   if (_active) {
 122     if (_verbose) {
 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 TraceCPUTime::TraceCPUTime(bool doit,
 144                bool print_cr,
 145                outputStream *logfile) :
 146   _active(doit),
 147   _print_cr(print_cr),
 148   _starting_user_time(0.0),
 149   _starting_system_time(0.0),
 150   _starting_real_time(0.0),
 151   _logfile(logfile),
 152   _error(false) {
 153   if (_active) {
 154     if (logfile != NULL) {
 155       _logfile = logfile;
 156     } else {
 157       _logfile = tty;
 158     }
 159 


   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  *


 120   _verbose = verbose;
 121   if (_active) {
 122     if (_verbose) {
 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),
 164   _starting_real_time(0.0),
 165   _logfile(logfile),
 166   _error(false) {
 167   if (_active) {
 168     if (logfile != NULL) {
 169       _logfile = logfile;
 170     } else {
 171       _logfile = tty;
 172     }
 173 


< prev index next >