| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 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, | |||
| 23 | ContextSwitch, | |||
| 24 | OutputPinSetValue, | |||
| 25 | DecodeTriggerEvent, | |||
| 26 | EnginePeriodicFastCallback, | |||
| 27 | EnginePeriodicSlowCallback, | |||
| 28 | EngineStatePeriodicFastCallback, | |||
| 29 | HandleShaftSignal, | |||
| 30 | EventQueueInsertTask, | |||
| 31 | EventQueueExecuteAll, | |||
| 32 | SingleTimerExecutorDoExecute, | |||
| 33 | SingleTimerExecutorScheduleTimerCallback, | |||
| 34 | PeriodicControllerPeriodicTask, | |||
| 35 | PeriodicTimerControllerPeriodicTask, //TODO: main_loop remove this after migrating to main_loop | |||
| 36 | AdcCallbackFast, | |||
| 37 | AdcProcessSlow, | |||
| 38 | AdcConversionSlow, | |||
| 39 | AdcConversionFast, | |||
| 40 | AdcSubscriptionUpdateSubscribers, | |||
| 41 | GetRunningFuel, | |||
| 42 | GetInjectionDuration, | |||
| 43 | HandleFuel, | |||
| 44 | MainTriggerCallback, | |||
| 45 | OnTriggerEventSparkLogic, | |||
| 46 | ShaftPositionListeners, | |||
| 47 | GetBaseFuel, | |||
| 48 | GetTpsEnrichment, | |||
| 49 | GetSpeedDensityFuel, | |||
| 50 | WallFuelAdjust, | |||
| 51 | MapAveragingTriggerCallback, | |||
| 52 | MainLoop, | |||
| 53 | SingleTimerExecutorScheduleByTimestamp, | |||
| 54 | GetTimeNowUs, | |||
| 55 | EventQueueExecuteCallback, | |||
| 56 | PwmGeneratorCallback, | |||
| 57 | TunerStudioHandleCrcCommand, | |||
| 58 | Unused, | |||
| 59 | PwmConfigStateChangeCallback, | |||
| 60 | Temporary1, | |||
| 61 | Temporary2, | |||
| 62 | Temporary3, | |||
| 63 | Temporary4, | |||
| 64 | EngineSniffer, | |||
| 65 | PrepareIgnitionSchedule, | |||
| 66 | Hip9011IntHoldCallback, | |||
| 67 | GlobalLock, | |||
| 68 | GlobalUnlock, | |||
| 69 | SoftwareKnockProcess, | |||
| 70 | KnockAnalyzer, | |||
| 71 | LogTriggerTooth, | |||
| 72 | LuaTickFunction, | |||
| 73 | LuaOneCanRxFunction, | |||
| 74 | LuaAllCanRxFunction, | |||
| 75 | LuaOneCanRxCallback, | |||
| 76 | LuaOneCanTxFunction, | |||
| 77 | CanThreadTx, | |||
| 78 | CanThreadRx, | |||
| 79 | CanDriverTx, | |||
| 80 | Temporary5, | |||
| 81 | Temporary6, | |||
| 82 | Temporary7, | |||
| 83 | Temporary8, | |||
| 84 | Temporary9, | |||
| 85 | Temporary10, | |||
| 86 | Temporary11, | |||
| 87 | Temporary12, | |||
| 88 | Temporary13, | |||
| 89 | Temporary14, | |||
| 90 | Temporary15, | |||
| 91 | Temporary16, | |||
| 92 | // enum_end_tag | |||
| 93 | // The tag above is consumed by PerfTraceTool.java | |||
| 94 | // please note that the tool requires a comma at the end of last value | |||
| 95 | }; | |||
| 96 | ||||
| 97 | void perfEventBegin(PE event); | |||
| 98 | void perfEventEnd(PE event); | |||
| 99 | void perfEventInstantGlobal(PE event); | |||
| 100 | ||||
| 101 | // Enable one buffer's worth of perf tracing, and retrieve the buffer size in bytes | |||
| 102 | void perfTraceEnable(); | |||
| 103 | ||||
| 104 | // Retrieve the trace buffer | |||
| 105 | const BigBufferHandle perfTraceGetBuffer(); | |||
| 106 | ||||
| 107 | #if ENABLE_PERF_TRACE | |||
| 108 | class ScopePerf | |||
| 109 | { | |||
| 110 | public: | |||
| 111 | ScopePerf(PE event) : m_event(event) { | |||
| 112 | perfEventBegin(event); | |||
| 113 | } | |||
| 114 | ||||
| 115 | ~ScopePerf() | |||
| 116 | { | |||
| 117 | perfEventEnd(m_event); | |||
| 118 | } | |||
| 119 | ||||
| 120 | private: | |||
| 121 | const PE m_event; | |||
| 122 | }; | |||
| 123 | ||||
| 124 | #else /* if ENABLE_PERF_TRACE */ | |||
| 125 | ||||
| 126 | struct ScopePerf { | |||
| 127 | 651758 | ScopePerf(PE) {} | ||
| 128 | }; | |||
| 129 | ||||
| 130 | #endif /* ENABLE_PERF_TRACE */ | |||
| 131 |