Home | History | Annotate | Download | only in test
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "base/test/perf_time_logger.h"
      6 
      7 #include "base/test/perf_log.h"
      8 
      9 namespace base {
     10 
     11 PerfTimeLogger::PerfTimeLogger(const char* test_name)
     12     : logged_(false), test_name_(test_name) {}
     13 
     14 PerfTimeLogger::~PerfTimeLogger() {
     15   if (!logged_)
     16     Done();
     17 }
     18 
     19 void PerfTimeLogger::Done() {
     20   // we use a floating-point millisecond value because it is more
     21   // intuitive than microseconds and we want more precision than
     22   // integer milliseconds
     23   LogPerfResult(test_name_.c_str(), timer_.Elapsed().InMillisecondsF(), "ms");
     24   logged_ = true;
     25 }
     26 
     27 }  // namespace base
     28