Proteus
Programmable JIT compilation and optimization for C/C++ using LLVM
Loading...
Searching...
No Matches
TimeTracing.h
Go to the documentation of this file.
1//===-- TimeTracing.h -- Time tracing helpers --===//
2//
3// Part of the Proteus Project, under the Apache License v2.0 with LLVM
4// Exceptions. See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef PROTEUS_TIME_TRACING_H
12#define PROTEUS_TIME_TRACING_H
13
14#include <chrono>
15#include <memory>
16
17namespace proteus {
18
19// RAII wrapper that handles the optional logic internally
20struct TimeTraceScopeWrapper;
22public:
23 explicit ScopedTimeTrace(const std::string &Name);
25
26 // Support only move-only construction.
29
30private:
31 std::unique_ptr<TimeTraceScopeWrapper> Pimpl;
32};
33
36
38};
39
40class Timer {
41 using Clock = std::chrono::steady_clock;
42
43public:
44 Timer();
45
46 uint64_t elapsed();
47
48 void reset();
49
50private:
51 Clock::time_point Start;
52};
53
54#define PROTEUS_TIMER_OUTPUT(x) \
55 if (Config::get().ProteusEnableTimers) \
56 x;
57
58// Macro now creates the wrapper, which is lightweight in the header.
59#define TIMESCOPE(x) proteus::ScopedTimeTrace STT_##__LINE__(x);
60
61} // namespace proteus
62
63#endif
Definition TimeTracing.h:21
ScopedTimeTrace(ScopedTimeTrace &&)=default
ScopedTimeTrace & operator=(ScopedTimeTrace &&)=default
Definition TimeTracing.h:40
Timer()
Definition TimeTracing.cpp:46
void reset()
Definition TimeTracing.cpp:57
uint64_t elapsed()
Definition TimeTracing.cpp:51
Definition MemoryCache.h:26
Definition TimeTracing.h:34
TimeTracerRAII()
Definition TimeTracing.cpp:27
~TimeTracerRAII()
Definition TimeTracing.cpp:33