WPILibC++ 2023.4.3-108-ge5452e3
ScopedTracer.h
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 "frc/Tracer.h"
11
12namespace wpi {
13class raw_ostream;
14} // namespace wpi
15
16namespace frc {
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 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 raw_ostream to print data to.
31 */
34
35 ScopedTracer(const ScopedTracer&) = delete;
37
38 private:
39 Tracer m_tracer;
40 std::string m_name;
41 wpi::raw_ostream& m_os;
42};
43} // namespace frc
A class for keeping track of how much time it takes for different parts of code to execute.
Definition: ScopedTracer.h:24
ScopedTracer & operator=(const ScopedTracer &)=delete
ScopedTracer(std::string_view name, wpi::raw_ostream &os)
Constructs a ScopedTracer instance.
ScopedTracer(const ScopedTracer &)=delete
A class for keeping track of how much time it takes for different parts of code to execute.
Definition: Tracer.h:26
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:44
basic_string_view< char > string_view
Definition: core.h:520
Definition: AprilTagPoseEstimator.h:15
Definition: AprilTagFieldLayout.h:18