Line data Source code
1 : /*
2 : * Copyright (C) 2025 aeml
3 : *
4 : * This program is free software: you can redistribute it and/or modify
5 : * it under the terms of the GNU General Public License as published by
6 : * the Free Software Foundation, either version 3 of the License, or
7 : * (at your option) any later version.
8 : *
9 : * This program is distributed in the hope that it will be useful,
10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : * GNU General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU General Public License
15 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 : */
17 :
18 : #include "core/Clock.hpp"
19 :
20 : #include <chrono>
21 :
22 : namespace core
23 : {
24 414 : double Clock::NowSeconds()
25 : {
26 : using clock = std::chrono::steady_clock;
27 414 : const auto now = clock::now().time_since_epoch();
28 414 : return std::chrono::duration<double>(now).count();
29 : }
30 :
31 2 : std::uint64_t Clock::NowMicroseconds()
32 : {
33 : using clock = std::chrono::steady_clock;
34 2 : const auto now = clock::now().time_since_epoch();
35 : return static_cast<std::uint64_t>(
36 2 : std::chrono::duration_cast<std::chrono::microseconds>(now).count());
37 : }
38 : }
|