WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
ScopedTracer.hpp
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <string>
8#include <string_view>
9
10#include "wpi/system/Tracer.hpp"
11
12namespace wpi::util {
13class raw_ostream;
14} // namespace wpi::util
15
16namespace wpi {
17/**
18 * A class for keeping track of how much time it takes for different
19 * parts of code to execute. This class uses RAII, meaning you simply
20 * need to create an instance at the top of the block you are timing. After the
21 * block finishes execution (i.e. when the ScopedTracer instance gets
22 * destroyed), the epoch is printed to the provided wpi::util::raw_ostream.
23 */
25 public:
26 /**
27 * Constructs a ScopedTracer instance.
28 *
29 * @param name The name of the epoch.
30 * @param os A reference to the wpi::util::raw_ostream to print data to.
31 */
32 ScopedTracer(std::string_view name, wpi::util::raw_ostream& os);
34
35 ScopedTracer(const ScopedTracer&) = delete;
37
38 private:
39 Tracer m_tracer;
40 std::string m_name;
41 wpi::util::raw_ostream& m_os;
42};
43} // namespace wpi
@ name
Definition base.h:690
ScopedTracer(std::string_view name, wpi::util::raw_ostream &os)
Constructs a ScopedTracer instance.
ScopedTracer(const ScopedTracer &)=delete
ScopedTracer & operator=(const ScopedTracer &)=delete
A class for keeping track of how much time it takes for different parts of code to execute.
Definition Tracer.hpp:26
Definition raw_os_ostream.hpp:19
Definition CvSource.hpp:15