rusEFI
The most advanced open source ECU
perf_trace.h
Go to the documentation of this file.
1 /**
2  * @file perf_trace.h
3  *
4  * https://github.com/rusefi/rusefi/wiki/Developer-Performance-Tracing
5  *
6  */
7 #pragma once
8 
9 #include "big_buffer.h"
10 
11 #include <cstdint>
12 #include <cstddef>
13 
14 // Defines different events we want to trace. These can be an interval (begin -> end), or an
15 // instant. Instants can be global, or specific to one thread. You probably don't want to use
16 // each element in PE more than once, as they should each indicate that a specific thing began,
17 // ended, or occurred.
18 enum class PE : uint8_t {
19  // The tag below is consumed by PerfTraceTool.java which generates EnumNames.java
20  // enum_start_tag
21  INVALID,
22  ISR,
43  HandleFuel,
52  Unused1,
58  Unused,
60  Temporary1,
61  Temporary2,
62  Temporary3,
63  Temporary4,
67  GlobalLock,
76  // enum_end_tag
77  // The tag above is consumed by PerfTraceTool.java
78  // please note that the tool requires a comma at the end of last value
79 };
80 
81 void perfEventBegin(PE event);
82 void perfEventEnd(PE event);
83 void perfEventInstantGlobal(PE event);
84 
85 // Enable one buffer's worth of perf tracing, and retrieve the buffer size in bytes
86 void perfTraceEnable();
87 
88 // Retrieve the trace buffer
90 
91 #if ENABLE_PERF_TRACE
92 class ScopePerf
93 {
94 public:
95  ScopePerf(PE event) : m_event(event) {
96  perfEventBegin(event);
97  }
98 
100  {
102  }
103 
104 private:
105  const PE m_event;
106 };
107 
108 #else /* if ENABLE_PERF_TRACE */
109 
110 struct ScopePerf {
112 };
113 
114 #endif /* ENABLE_PERF_TRACE */
const PE m_event
Definition: perf_trace.h:105
ScopePerf(PE event)
Definition: perf_trace.h:95
ScopePerf(PE)
Definition: perf_trace.h:111
~ScopePerf()
Definition: perf_trace.h:99
void perfEventInstantGlobal(PE event)
Definition: perf_trace.cpp:115
const BigBufferHandle perfTraceGetBuffer()
Definition: perf_trace.cpp:132
void perfEventBegin(PE event)
Definition: perf_trace.cpp:107
void perfTraceEnable()
Definition: perf_trace.cpp:119
PE
Definition: perf_trace.h:18
@ GetInjectionDuration
@ OnTriggerEventSparkLogic
@ Temporary4
@ HandleShaftSignal
@ ContextSwitch
@ EnginePeriodicSlowCallback
@ Temporary2
@ LuaOneCanTxFunction
@ PwmGeneratorCallback
@ EventQueueExecuteAll
@ PrepareIgnitionSchedule
@ GetBaseFuel
@ ShaftPositionListeners
@ AdcConversionFast
@ SingleTimerExecutorDoExecute
@ OutputPinSetValue
@ SingleTimerExecutorScheduleByTimestamp
@ SingleTimerExecutorScheduleTimerCallback
@ EventQueueInsertTask
@ PwmConfigStateChangeCallback
@ LuaOneCanRxCallback
@ GetTimeNowUs
@ MapAveragingTriggerCallback
@ TunerStudioHandleCrcCommand
@ LuaTickFunction
@ MainTriggerCallback
@ LuaAllCanRxFunction
@ LogTriggerTooth
@ EngineSniffer
@ DecodeTriggerEvent
@ Temporary1
@ EnginePeriodicFastCallback
@ Unused
@ LuaOneCanRxFunction
@ Temporary3
@ AdcConversionSlow
@ SoftwareKnockProcess
@ EngineStatePeriodicFastCallback
@ GetSpeedDensityFuel
@ AdcProcessSlow
@ AdcSubscriptionUpdateSubscribers
@ WallFuelAdjust
@ HandleFuel
@ Hip9011IntHoldCallback
@ EventQueueExecuteCallback
@ GetRunningFuel
@ PeriodicControllerPeriodicTask
@ ISR
@ INVALID
@ GetTpsEnrichment
@ GlobalUnlock
@ GlobalLock
@ PeriodicTimerControllerPeriodicTask
@ Unused1
@ AdcCallbackFast
void perfEventEnd(PE event)
Definition: perf_trace.cpp:111