Serenity Operating System
1/*
2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#pragma once
8
9#include <AK/Time.h>
10
11namespace Core {
12
13class ElapsedTimer {
14public:
15 static ElapsedTimer start_new();
16
17 ElapsedTimer(bool precise = false)
18 : m_precise(precise)
19 {
20 }
21
22 bool is_valid() const { return m_valid; }
23 void start();
24 void reset();
25
26 i64 elapsed() const; // milliseconds
27 Time elapsed_time() const;
28
29 Time const& origin_time() const { return m_origin_time; }
30
31private:
32 Time m_origin_time {};
33 bool m_precise { false };
34 bool m_valid { false };
35};
36
37}