#pragma once

#include "Common.h"
#include "Logger.h"

#include <chrono>
#include <string>

namespace Aurora {
    class CalcRunTime final : public noncopyable {
    public:
        explicit CalcRunTime(std::string name)
                : m_name(std::move(name)),
                  m_start(std::chrono::system_clock::now()) {
        }

        ~CalcRunTime() {
            auto now = std::chrono::system_clock::now();
            auto duration = std::chrono::duration_cast<std::chrono::microseconds>(now - m_start);

            auto seconds = static_cast<double>(duration.count()) * std::chrono::microseconds::period::num /
                           std::chrono::microseconds::period::den;

            LOGGER.Info("CalcRunTime name:%s time:%f seconds", m_name.c_str(), seconds);
        }

    private:
        std::string m_name;
        std::chrono::system_clock::time_point m_start;
    };
}