hotspot/src/share/vm/runtime/timer.cpp
changeset 37161 e881f320966e
parent 37043 5aa55674a362
equal deleted inserted replaced
37157:2a0fdb3e2a19 37161:e881f320966e
   112 jlong TimeStamp::ticks_since_update() const {
   112 jlong TimeStamp::ticks_since_update() const {
   113   assert(is_updated(), "must not be clear");
   113   assert(is_updated(), "must not be clear");
   114   return os::elapsed_counter() - _counter;
   114   return os::elapsed_counter() - _counter;
   115 }
   115 }
   116 
   116 
   117 TraceTime::TraceTime(const char* title,
       
   118                      bool doit,
       
   119                      LogTagType tag) {
       
   120   _active   = doit;
       
   121   _verbose  = true;
       
   122   _tag      = tag;
       
   123   _title    = title;
       
   124 
       
   125   if (_active) {
       
   126     _accum = NULL;
       
   127     _t.start();
       
   128   }
       
   129 }
       
   130 
       
   131 TraceTime::TraceTime(const char* title,
       
   132                      elapsedTimer* accumulator,
       
   133                      bool doit,
       
   134                      bool verbose,
       
   135                      LogTagType tag) {
       
   136   _active   = doit;
       
   137   _verbose  = verbose;
       
   138   _tag      = tag;
       
   139   _title    = title;
       
   140 
       
   141   if (_active) {
       
   142     _accum = accumulator;
       
   143     _t.start();
       
   144   }
       
   145 }
       
   146 
       
   147 TraceTime::~TraceTime() {
       
   148   if (_active) {
       
   149     _t.stop();
       
   150     if (_accum!=NULL) _accum->add(_t);
       
   151     if (_verbose) {
       
   152       switch (_tag) {
       
   153         case LogTag::_startuptime :
       
   154           log_info(startuptime)("%s, %3.7f secs", _title, _t.seconds());
       
   155           break;
       
   156         case LogTag::_safepointcleanup :
       
   157           log_info(safepointcleanup)("%s, %3.7f secs", _title, _t.seconds());
       
   158           break;
       
   159         case LogTag::__NO_TAG :
       
   160        default :
       
   161           tty->print_cr("[%s, %3.7f secs]", _title, _t.seconds());
       
   162           tty->flush();
       
   163       }
       
   164     }
       
   165   }
       
   166 }
       
   167 
       
   168 TraceCPUTime::TraceCPUTime(bool doit,
   117 TraceCPUTime::TraceCPUTime(bool doit,
   169                bool print_cr,
   118                bool print_cr,
   170                outputStream *logfile) :
   119                outputStream *logfile) :
   171   _active(doit),
   120   _active(doit),
   172   _print_cr(print_cr),
   121   _print_cr(print_cr),
   217       _logfile->cr();
   166       _logfile->cr();
   218     }
   167     }
   219     _logfile->flush();
   168     _logfile->flush();
   220   }
   169   }
   221 }
   170 }
       
   171