Home | History | Annotate | Download | only in test
      1 /*
      2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #include "TimedTrace.h"
     12 #include <math.h>
     13 
     14 double TimedTrace::_timeEllapsedSec = 0;
     15 FILE* TimedTrace::_timedTraceFile = NULL;
     16 
     17 TimedTrace::TimedTrace() {
     18 
     19 }
     20 
     21 TimedTrace::~TimedTrace() {
     22   if (_timedTraceFile != NULL) {
     23     fclose(_timedTraceFile);
     24   }
     25   _timedTraceFile = NULL;
     26 }
     27 
     28 int16_t TimedTrace::SetUp(char* fileName) {
     29   if (_timedTraceFile == NULL) {
     30     _timedTraceFile = fopen(fileName, "w");
     31   }
     32   if (_timedTraceFile == NULL) {
     33     return -1;
     34   }
     35   return 0;
     36 }
     37 
     38 void TimedTrace::SetTimeEllapsed(double timeEllapsedSec) {
     39   _timeEllapsedSec = timeEllapsedSec;
     40 }
     41 
     42 double TimedTrace::TimeEllapsed() {
     43   return _timeEllapsedSec;
     44 }
     45 
     46 void TimedTrace::Tick10Msec() {
     47   _timeEllapsedSec += 0.010;
     48 }
     49 
     50 void TimedTrace::TimedLogg(char* message) {
     51   unsigned int minutes = (uint32_t) floor(_timeEllapsedSec / 60.0);
     52   double seconds = _timeEllapsedSec - minutes * 60;
     53   //char myFormat[100] = "%8.2f, %3u:%05.2f: %s\n";
     54   if (_timedTraceFile != NULL) {
     55     fprintf(_timedTraceFile, "%8.2f, %3u:%05.2f: %s\n", _timeEllapsedSec,
     56             minutes, seconds, message);
     57   }
     58 }
     59