imsuck's library

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub imsuck/library

:warning: other/timer.hpp

Code

#pragma once

namespace timer {
    using namespace chrono;
    static auto last = steady_clock::now();
    map<string, uint64_t> comp;
    template<bool final = false>
    void add([[maybe_unused]] string const &msg = "") {
#ifdef LOCAL
        auto now = steady_clock::now();
        auto delta = duration_cast<microseconds>(now - last).count();
        last = now;
        if (msg.size() && !final) comp[msg] += delta;

        if (final) {
            long double tot = 0;
            for (auto &[k, v] : comp)
                tot += v * 1e-3L, cerr << k << ": " << v * 1e-3L << " ms\n";
            cerr << "total: " << tot << " ms\n";
        }
#endif
    }
} // namespace timer
#line 2 "other/timer.hpp"

namespace timer {
    using namespace chrono;
    static auto last = steady_clock::now();
    map<string, uint64_t> comp;
    template<bool final = false>
    void add([[maybe_unused]] string const &msg = "") {
#ifdef LOCAL
        auto now = steady_clock::now();
        auto delta = duration_cast<microseconds>(now - last).count();
        last = now;
        if (msg.size() && !final) comp[msg] += delta;

        if (final) {
            long double tot = 0;
            for (auto &[k, v] : comp)
                tot += v * 1e-3L, cerr << k << ": " << v * 1e-3L << " ms\n";
            cerr << "total: " << tot << " ms\n";
        }
#endif
    }
} // namespace timer
Back to top page