diff options
Diffstat (limited to 'include/mbgl/util/monotonic_timer.hpp')
-rw-r--r-- | include/mbgl/util/monotonic_timer.hpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/mbgl/util/monotonic_timer.hpp b/include/mbgl/util/monotonic_timer.hpp new file mode 100644 index 000000000..bdb167214 --- /dev/null +++ b/include/mbgl/util/monotonic_timer.hpp @@ -0,0 +1,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
\ No newline at end of file |