summaryrefslogtreecommitdiff
path: root/include/mbgl/util/monotonic_timer.hpp
blob: bdb167214bdcb4d6e23346e717983b08508a898a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#pragma once

#include <chrono>
#include <functional>
#include <mbgl/util/noncopyable.hpp>
#include <memory>

namespace mbgl {
namespace util {

class MonotonicTimer {
public:
    static std::chrono::duration<double> now();

    template <typename F, typename... Args>
    inline static std::chrono::duration<double> duration(F&& func, Args&&... args) {
        auto start = now();
        func(std::forward<Args>(args)...);
        return now() - start;
    }
};

} // namespace util
} // namespace mbgl