/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#include <chrono>
#include <iostream>
#include <string>

#include "timer.hpp"

UTimer::UTimer() : TimeStart(std::chrono::high_resolution_clock::now()) {
    TimeElapsed = std::chrono::high_resolution_clock::now() - TimeStart;
    Timeusec =
        std::chrono::duration_cast<std::chrono::microseconds>(TimeElapsed)
            .count();
}

void UTimer::start() { TimeStart = std::chrono::high_resolution_clock::now(); }

void UTimer::stop() {
    TimeElapsed = std::chrono::high_resolution_clock::now() - TimeStart;
    Timeusec =
        std::chrono::duration_cast<std::chrono::microseconds>(TimeElapsed)
            .count();
}

long long int UTimer::print(const std::string &s) {
    std::cout << s << "\t" << Timeusec << " usecs" << std::endl;
    return Timeusec;
}
