gtsam_points
Loading...
Searching...
No Matches
stopwatch.hpp
1// SPDX-FileCopyrightText: Copyright 2024 Kenji Koide
2// SPDX-License-Identifier: MIT
3#pragma once
4
5#include <chrono>
6
7namespace gtsam_points {
8
10struct Stopwatch {
11public:
12 void start() { t1 = t2 = std::chrono::high_resolution_clock::now(); }
13 void stop() { t2 = std::chrono::high_resolution_clock::now(); }
14 void lap() {
15 t1 = t2;
16 t2 = std::chrono::high_resolution_clock::now();
17 }
18
19 double sec() const { return std::chrono::duration_cast<std::chrono::nanoseconds>(t2 - t1).count() / 1e9; }
20 double msec() const { return std::chrono::duration_cast<std::chrono::nanoseconds>(t2 - t1).count() / 1e6; }
21
22public:
23 std::chrono::high_resolution_clock::time_point t1;
24 std::chrono::high_resolution_clock::time_point t2;
25};
26
27} // namespace gtsam_points
Just a stopwatch.
Definition stopwatch.hpp:10