sotanishy's competitive programming library

sotanishy's code snippets for competitive programming

View the Project on GitHub sotanishy/cp-library-cpp

:warning: misc/timer.hpp

Code

#pragma once
#include <chrono>

class Timer {
   public:
    void start() { start_time = std::chrono::steady_clock::now(); }

    long long get_time() const {
        auto cur_time = std::chrono::steady_clock::now();
        return std::chrono::duration_cast<std::chrono::milliseconds>(cur_time -
                                                                     start_time)
            .count();
    }

   private:
    std::chrono::steady_clock::time_point start_time;
};
#line 2 "misc/timer.hpp"
#include <chrono>

class Timer {
   public:
    void start() { start_time = std::chrono::steady_clock::now(); }

    long long get_time() const {
        auto cur_time = std::chrono::steady_clock::now();
        return std::chrono::duration_cast<std::chrono::milliseconds>(cur_time -
                                                                     start_time)
            .count();
    }

   private:
    std::chrono::steady_clock::time_point start_time;
};
Back to top page