LCOV - code coverage report
Current view: top level - firmware/development - perf_trace.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2024-04-25 02:23:43 Functions: 1 1 100.0 %

          Line data    Source code
       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,
      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             :         Unused1,
      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             :         LogTriggerTooth,
      71             :         LuaTickFunction,
      72             :         LuaOneCanRxFunction,
      73             :         LuaAllCanRxFunction,
      74             :         LuaOneCanRxCallback,
      75             :   LuaOneCanTxFunction,
      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
      89             : const BigBufferHandle perfTraceGetBuffer();
      90             : 
      91             : #if ENABLE_PERF_TRACE
      92             : class ScopePerf
      93             : {
      94             : public:
      95             :         ScopePerf(PE event) : m_event(event) {
      96             :                 perfEventBegin(event);
      97             :         }
      98             : 
      99             :         ~ScopePerf()
     100             :         {
     101             :                 perfEventEnd(m_event);
     102             :         }
     103             : 
     104             : private:
     105             :         const PE m_event;
     106             : };
     107             : 
     108             : #else /* if ENABLE_PERF_TRACE */
     109             : 
     110             : struct ScopePerf {
     111      372361 :         ScopePerf(PE) {}
     112             : };
     113             : 
     114             : #endif /* ENABLE_PERF_TRACE */

Generated by: LCOV version 1.14