< prev index next >

src/share/vm/runtime/timer.cpp

Print this page
rev 8477 : 8085975: Fix warning "converting to jlong from double" of gcc 4.1.2 after 8079561
   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  *


  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) {
  52     _counter += os::elapsed_counter() - _start_counter;
  53     _active = false;
  54   }
  55 }
  56 
  57 double elapsedTimer::seconds() const {
  58  return TimeHelper::counter_to_seconds(_counter);
  59 }
  60 
  61 jlong elapsedTimer::milliseconds() const {
  62   return TimeHelper::counter_to_millis(_counter);
  63 }
  64 
  65 jlong elapsedTimer::active_ticks() const {
  66   if (!_active) {
  67     return ticks();
  68   }
  69   jlong counter = _counter + os::elapsed_counter() - _start_counter;
  70   return counter;
  71 }
  72 
  73 void TimeStamp::update_to(jlong ticks) {
  74   _counter = ticks;
  75   if (_counter == 0)  _counter = 1;
  76   assert(is_updated(), "must not look clear");
  77 }
  78 
  79 void TimeStamp::update() {
  80   update_to(os::elapsed_counter());
  81 }
  82 
  83 double TimeStamp::seconds() const {
  84   assert(is_updated(), "must not be clear");
  85   jlong new_count = os::elapsed_counter();
  86   return TimeHelper::counter_to_seconds(new_count - _counter);
  87 }
  88 
  89 jlong TimeStamp::milliseconds() const {
  90   assert(is_updated(), "must not be clear");
  91   jlong new_count = os::elapsed_counter();
  92   return TimeHelper::counter_to_millis(new_count - _counter);
  93 }
  94 
  95 jlong TimeStamp::ticks_since_update() const {
  96   assert(is_updated(), "must not be clear");
  97   return os::elapsed_counter() - _counter;
  98 }
  99 
 100 TraceTime::TraceTime(const char* title,
 101                      bool doit) {
 102   _active   = doit;
 103   _verbose  = true;
 104 
 105   if (_active) {
 106     _accum = NULL;
 107     tty->stamp(PrintGCTimeStamps);
 108     tty->print("[%s", title);
 109     tty->flush();
 110     _t.start();
 111   }
 112 }


   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  *


  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) {
  52     _counter += os::elapsed_counter() - _start_counter;
  53     _active = false;
  54   }
  55 }
  56 
  57 double elapsedTimer::seconds() const {
  58  return TimeHelper::counter_to_seconds(_counter);
  59 }
  60 
  61 jlong elapsedTimer::milliseconds() const {
  62   return (jlong)TimeHelper::counter_to_millis(_counter);
  63 }
  64 
  65 jlong elapsedTimer::active_ticks() const {
  66   if (!_active) {
  67     return ticks();
  68   }
  69   jlong counter = _counter + os::elapsed_counter() - _start_counter;
  70   return counter;
  71 }
  72 
  73 void TimeStamp::update_to(jlong ticks) {
  74   _counter = ticks;
  75   if (_counter == 0)  _counter = 1;
  76   assert(is_updated(), "must not look clear");
  77 }
  78 
  79 void TimeStamp::update() {
  80   update_to(os::elapsed_counter());
  81 }
  82 
  83 double TimeStamp::seconds() const {
  84   assert(is_updated(), "must not be clear");
  85   jlong new_count = os::elapsed_counter();
  86   return TimeHelper::counter_to_seconds(new_count - _counter);
  87 }
  88 
  89 jlong TimeStamp::milliseconds() const {
  90   assert(is_updated(), "must not be clear");
  91   jlong new_count = os::elapsed_counter();
  92   return (jlong)TimeHelper::counter_to_millis(new_count - _counter);
  93 }
  94 
  95 jlong TimeStamp::ticks_since_update() const {
  96   assert(is_updated(), "must not be clear");
  97   return os::elapsed_counter() - _counter;
  98 }
  99 
 100 TraceTime::TraceTime(const char* title,
 101                      bool doit) {
 102   _active   = doit;
 103   _verbose  = true;
 104 
 105   if (_active) {
 106     _accum = NULL;
 107     tty->stamp(PrintGCTimeStamps);
 108     tty->print("[%s", title);
 109     tty->flush();
 110     _t.start();
 111   }
 112 }


< prev index next >