<commit_before>#include "timer.h"
#include <iostream>
using namespace std;
// Google Libraries
//#include <glog/logging.h>
//using namespace google;

namespace utils {
  using namespace boost::posix_time;
  
  double subtractTimes( ptime endTime, ptime startTime) {
    static const double micro_in_one_sec = static_cast<double>(
      time_duration(seconds(1)).total_microseconds());
    double elapsed = static_cast<double>(
      (endTime - startTime).total_microseconds()
      / micro_in_one_sec);
    return elapsed;
  }


  Timer::Timer(const char* name) {
    mCount = 0;
    mTotal = 0;
    mName = new char[64];
    strcpy(mName, name);
    bRunning = false;
  }

  Timer::~Timer() {
    print();
    delete[] mName;
  }

  void Timer::startTimer() {
    bRunning = true;
    mCount++;
    mStart = microsec_clock::local_time();
  }

  double Timer::elapsed() {
    ptime now = microsec_clock::local_time();
    mLastElapsed = subtractTimes(now, mStart);
    return mLastElapsed;
  }

  double Timer::lastElapsed() const {
    return mLastElapsed;
  }

  void Timer::stopTimer() {
    bRunning = false;
    mStop = microsec_clock::local_time();
    mLastElapsed = subtractTimes(mStop, mStart);
    mTotal += mLastElapsed;
  }

  bool Timer::isRunning() const {
    return bRunning;
  }

  void Timer::print() {
    //if(mCount>0) {
    //  VLOG(1) << "Timer [" << mName << "] : "
    //          << "Last = " << mLastElapsed << " "
    //          << "Total " << " "
    //          << mTotal << " " << mCount << "; "
    //          << "Average: " << mTotal / mCount << " "
    //          << "FPS : " << mCount / mTotal << "hz ";
    //   
    //} else {
    //  VLOG(1) << "Timer " << mName << " doesn't have any record." << endl;
    //}
  }

  scoped_timer::scoped_timer(Timer* _timer)
    : timer_(_timer) {
    timer()->startTimer();
  }

  scoped_timer::~scoped_timer() {
    timer()->stopTimer();
  }

  Timer* scoped_timer::timer() const {
    return timer_;
  }

} // namespace utils<commit_msg>change the timer.cpp back. I commented two places about VLOG in the previous version because I have not downloaded that library yet.<commit_after>#include "timer.h"
#include <iostream>
using namespace std;
// Google Libraries
#include <glog/logging.h>
using namespace google;

namespace utils {
  using namespace boost::posix_time;
  
  double subtractTimes( ptime endTime, ptime startTime) {
    static const double micro_in_one_sec = static_cast<double>(
      time_duration(seconds(1)).total_microseconds());
    double elapsed = static_cast<double>(
      (endTime - startTime).total_microseconds()
      / micro_in_one_sec);
    return elapsed;
  }


  Timer::Timer(const char* name) {
    mCount = 0;
    mTotal = 0;
    mName = new char[64];
    strcpy(mName, name);
    bRunning = false;
  }

  Timer::~Timer() {
    print();
    delete[] mName;
  }

  void Timer::startTimer() {
    bRunning = true;
    mCount++;
    mStart = microsec_clock::local_time();
  }

  double Timer::elapsed() {
    ptime now = microsec_clock::local_time();
    mLastElapsed = subtractTimes(now, mStart);
    return mLastElapsed;
  }

  double Timer::lastElapsed() const {
    return mLastElapsed;
  }

  void Timer::stopTimer() {
    bRunning = false;
    mStop = microsec_clock::local_time();
    mLastElapsed = subtractTimes(mStop, mStart);
    mTotal += mLastElapsed;
  }

  bool Timer::isRunning() const {
    return bRunning;
  }

  void Timer::print() {
    if(mCount>0) {
      VLOG(1) << "Timer [" << mName << "] : "
              << "Last = " << mLastElapsed << " "
              << "Total " << " "
              << mTotal << " " << mCount << "; "
              << "Average: " << mTotal / mCount << " "
              << "FPS : " << mCount / mTotal << "hz ";
       
    } else {
      VLOG(1) << "Timer " << mName << " doesn't have any record." << endl;
    }
  }

  scoped_timer::scoped_timer(Timer* _timer)
    : timer_(_timer) {
    timer()->startTimer();
  }

  scoped_timer::~scoped_timer() {
    timer()->stopTimer();
  }

  Timer* scoped_timer::timer() const {
    return timer_;
  }

} // namespace utils
{'fraction_non_alphanumeric': 0.15442424242424244, 'fraction_numerical': 0.0038787878787878787, 'mean_word_length': 2.6675555555555555, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5693091', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1374, 'n_words': 290}