#include "stopwatch.hpp"

#include <cmath>
#include <chrono>


Stopwatch::Stopwatch() : running(false) {}

void Stopwatch::start() {
    t_start = std::chrono::steady_clock::now();
    running = true;
}

double Stopwatch::stop() {
    if (!running) { return 0; }
    else {
        running = false;
        // (time_point - time_point) = std::chrono::duration, not double
        return std::chrono::duration<double>(std::chrono::steady_clock::now() - t_start).count();
    }
}

