#include "application/runtime/ApplicationLoopDiagnostics.h"

#include "foundation/diagnostics/Metrics.h"

namespace ta::application::diagnostics
{
    namespace
    {
        ta::foundation::diagnostics::TimingMetric application_update_timing;
        ta::foundation::diagnostics::TimingMetric gameworld_update_timing;
    }

    void reset_application_loop() noexcept
    {
        application_update_timing.reset();
        gameworld_update_timing.reset();
    }

    void record_application_update_duration(const std::uint64_t nanoseconds) noexcept
    {
        application_update_timing.record(nanoseconds);
    }

    void record_gameworld_update_duration(const std::uint64_t nanoseconds) noexcept
    {
        gameworld_update_timing.record(nanoseconds);
    }

    ApplicationLoopDiagnosticsSnapshot application_loop_snapshot() noexcept
    {
        return {application_update_timing.snapshot(), gameworld_update_timing.snapshot()};
    }
}
