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-07-26 21:23:12 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             :         KnockAnalyzer,
      71             :         LogTriggerTooth,
      72             :         LuaTickFunction,
      73             :         LuaOneCanRxFunction,
      74             :         LuaAllCanRxFunction,
      75             :         LuaOneCanRxCallback,
      76             :   LuaOneCanTxFunction,
      77             :         // enum_end_tag
      78             :         // The tag above is consumed by PerfTraceTool.java
      79             :         // please note that the tool requires a comma at the end of last value
      80             : };
      81             : 
      82             : void perfEventBegin(PE event);
      83             : void perfEventEnd(PE event);
      84             : void perfEventInstantGlobal(PE event);
      85             : 
      86             : // Enable one buffer's worth of perf tracing, and retrieve the buffer size in bytes
      87             : void perfTraceEnable();
      88             : 
      89             : // Retrieve the trace buffer
      90             : const BigBufferHandle perfTraceGetBuffer();
      91             : 
      92             : #if ENABLE_PERF_TRACE
      93             : class ScopePerf
      94             : {
      95             : public:
      96             :         ScopePerf(PE event) : m_event(event) {
      97             :                 perfEventBegin(event);
      98             :         }
      99             : 
     100             :         ~ScopePerf()
     101             :         {
     102             :                 perfEventEnd(m_event);
     103             :         }
     104             : 
     105             : private:
     106             :         const PE m_event;
     107             : };
     108             : 
     109             : #else /* if ENABLE_PERF_TRACE */
     110             : 
     111             : struct ScopePerf {
     112      430102 :         ScopePerf(PE) {}
     113             : };
     114             : 
     115             : #endif /* ENABLE_PERF_TRACE */

Generated by: LCOV version 1.14