library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub rajyan/library

:heavy_check_mark: src/Timer.hpp

Verified with

Code

#pragma once

#include <chrono>

using namespace std;

class Timer {
public:
    Timer() { reset(); }

    void reset() {
        start = chrono::high_resolution_clock::now();
    }

    [[nodiscard]] chrono::microseconds::rep elapsed() const {
        auto end = chrono::high_resolution_clock::now();
        return chrono::duration_cast<chrono::microseconds>(end - start).count();
    }

private:
    chrono::high_resolution_clock::time_point start;
};
#line 2 "src/Timer.hpp"

#include <chrono>

using namespace std;

class Timer {
public:
    Timer() { reset(); }

    void reset() {
        start = chrono::high_resolution_clock::now();
    }

    [[nodiscard]] chrono::microseconds::rep elapsed() const {
        auto end = chrono::high_resolution_clock::now();
        return chrono::duration_cast<chrono::microseconds>(end - start).count();
    }

private:
    chrono::high_resolution_clock::time_point start;
};
Back to top page