#include "timer.h"

void start_timer(Timer *timer) {
  if (timer->running) {
    return;
  }

  timer->running = true;
  timer->start_time = std::chrono::steady_clock::now();
}

f32 stop_timer(Timer *timer) {
  if (!timer->running) {
    return 0;
  }

  timer->running = false;
  auto stop_time = std::chrono::steady_clock::now();
  f32 timer_milliseconds = std::chrono::duration_cast<std::chrono::microseconds>(stop_time - timer->start_time).count() / 1000.0f;

  return timer_milliseconds;
}
