//
// Created by sasha on 03.12.2025.
//

#include "Profiler.h"
#include "SDL3/SDL_log.h"

Profiler::Profiler() {
    point_start_global = std::chrono::high_resolution_clock::now();

}

void Profiler::start() {
    point_start = std::chrono::high_resolution_clock::now();
}

void Profiler::timestamp(const std::string &tag) {
    auto point_end = std::chrono::high_resolution_clock::now();

    // Вычисляем разницу
    std::chrono::duration<double, std::milli> duration = point_end - point_start;

    SDL_Log("[%s] Время выполнения: %.5f секунд", tag.c_str(), duration.count()/1000);

    start();
}

void Profiler::stop(const std::string &tag) {
    auto point_end = std::chrono::high_resolution_clock::now();
    // Вычисляем разницу
    std::chrono::duration<double, std::milli> duration = point_end - point_start_global;

    SDL_Log("[%s] STOP: %.5f секунд", tag.c_str(), duration.count()/1000);
}
