CTRE Phoenix C++ 5.33.1
Stopwatch.h
Go to the documentation of this file.
1/* Copyright (C) Cross The Road Electronics 2024 */
2#pragma once
3
4#include <chrono>
5#include <cstdint>
6
7namespace ctre {
8namespace phoenix {
9
10/**
11 * Stopwatch to track time in milliseconds
12 */
13class Stopwatch {
14public:
15 /**
16 * Start the stopwatch
17 */
18 void Start();
19 /**
20 * @return Current time elapsed since start in ms
21 */
22 long long int DurationMs();
23 /**
24 * @return Current time elapsed since start in s
25 */
26 double Duration();
27
28private:
29 std::chrono::steady_clock::time_point _t0 = std::chrono::steady_clock::now();
30 std::chrono::steady_clock::time_point _t1 = std::chrono::steady_clock::now();
31};
32
33}}
Stopwatch to track time in milliseconds.
Definition: Stopwatch.h:13
void Start()
Start the stopwatch.
long long int DurationMs()
namespace ctre
Definition: paramEnum.h:5