2019-11-24 21:57:36 -08:00
|
|
|
/**
|
|
|
|
* @file perf_trace.h
|
|
|
|
*
|
2021-12-29 12:38:35 -08:00
|
|
|
* https://github.com/rusefi/rusefi/wiki/Developer-Performance-Tracing
|
|
|
|
*
|
2019-11-24 21:57:36 -08:00
|
|
|
*/
|
2019-10-11 17:43:21 -07:00
|
|
|
#pragma once
|
|
|
|
|
2022-12-10 04:35:39 -08:00
|
|
|
#include "big_buffer.h"
|
|
|
|
|
2019-10-11 17:43:21 -07:00
|
|
|
#include <cstdint>
|
2019-10-14 23:34:12 -07:00
|
|
|
#include <cstddef>
|
2019-10-11 17:43:21 -07:00
|
|
|
|
|
|
|
// Defines different events we want to trace. These can be an interval (begin -> end), or an
|
|
|
|
// instant. Instants can be global, or specific to one thread. You probably don't want to use
|
|
|
|
// each element in PE more than once, as they should each indicate that a specific thing began,
|
2019-12-01 17:31:18 -08:00
|
|
|
// ended, or occurred.
|
2019-10-11 17:43:21 -07:00
|
|
|
enum class PE : uint8_t {
|
2020-10-03 21:15:40 -07:00
|
|
|
// The tag below is consumed by PerfTraceTool.java which generates EnumNames.java
|
2019-11-24 21:57:36 -08:00
|
|
|
// enum_start_tag
|
2019-10-13 13:14:08 -07:00
|
|
|
INVALID,
|
2019-10-11 17:43:21 -07:00
|
|
|
ISR,
|
|
|
|
ContextSwitch,
|
|
|
|
OutputPinSetValue,
|
|
|
|
DecodeTriggerEvent,
|
|
|
|
EnginePeriodicFastCallback,
|
|
|
|
EnginePeriodicSlowCallback,
|
|
|
|
EngineStatePeriodicFastCallback,
|
|
|
|
HandleShaftSignal,
|
|
|
|
EventQueueInsertTask,
|
|
|
|
EventQueueExecuteAll,
|
|
|
|
SingleTimerExecutorDoExecute,
|
|
|
|
SingleTimerExecutorScheduleTimerCallback,
|
|
|
|
PeriodicControllerPeriodicTask,
|
|
|
|
PeriodicTimerControllerPeriodicTask,
|
|
|
|
AdcCallbackFast,
|
2019-12-11 06:28:11 -08:00
|
|
|
AdcProcessSlow,
|
2019-10-11 17:43:21 -07:00
|
|
|
AdcConversionSlow,
|
|
|
|
AdcConversionFast,
|
|
|
|
AdcSubscriptionUpdateSubscribers,
|
2019-10-13 13:14:08 -07:00
|
|
|
GetRunningFuel,
|
|
|
|
GetInjectionDuration,
|
|
|
|
HandleFuel,
|
|
|
|
MainTriggerCallback,
|
|
|
|
OnTriggerEventSparkLogic,
|
|
|
|
ShaftPositionListeners,
|
|
|
|
GetBaseFuel,
|
|
|
|
GetTpsEnrichment,
|
|
|
|
GetSpeedDensityFuel,
|
|
|
|
WallFuelAdjust,
|
|
|
|
MapAveragingTriggerCallback,
|
2021-07-23 11:19:59 -07:00
|
|
|
Unused1,
|
2019-10-13 13:14:08 -07:00
|
|
|
SingleTimerExecutorScheduleByTimestamp,
|
2019-12-10 18:18:35 -08:00
|
|
|
GetTimeNowUs,
|
2019-10-13 13:14:08 -07:00
|
|
|
EventQueueExecuteCallback,
|
|
|
|
PwmGeneratorCallback,
|
2019-10-14 23:34:12 -07:00
|
|
|
TunerStudioHandleCrcCommand,
|
2020-10-05 05:23:30 -07:00
|
|
|
Unused,
|
2019-10-14 23:34:12 -07:00
|
|
|
PwmConfigStateChangeCallback,
|
2019-12-10 19:18:37 -08:00
|
|
|
Temporary1,
|
|
|
|
Temporary2,
|
|
|
|
Temporary3,
|
|
|
|
Temporary4,
|
2019-12-23 17:22:17 -08:00
|
|
|
EngineSniffer,
|
2020-03-24 17:19:19 -07:00
|
|
|
PrepareIgnitionSchedule,
|
|
|
|
Hip9011IntHoldCallback,
|
2020-07-10 20:27:27 -07:00
|
|
|
GlobalLock,
|
|
|
|
GlobalUnlock,
|
2020-08-28 18:13:50 -07:00
|
|
|
SoftwareKnockProcess,
|
2020-10-03 21:15:40 -07:00
|
|
|
LogTriggerTooth,
|
2021-04-28 19:41:25 -07:00
|
|
|
LuaTickFunction,
|
2019-11-24 21:57:36 -08:00
|
|
|
// enum_end_tag
|
|
|
|
// The tag above is consumed by PerfTraceTool.java
|
|
|
|
// please note that the tool requires a comma at the end of last value
|
2019-10-11 17:43:21 -07:00
|
|
|
};
|
|
|
|
|
2020-04-29 07:53:35 -07:00
|
|
|
void perfEventBegin(PE event);
|
|
|
|
void perfEventEnd(PE event);
|
|
|
|
void perfEventInstantGlobal(PE event);
|
2019-10-11 17:43:21 -07:00
|
|
|
|
2019-10-14 23:34:12 -07:00
|
|
|
// Enable one buffer's worth of perf tracing, and retrieve the buffer size in bytes
|
2019-10-14 23:40:51 -07:00
|
|
|
void perfTraceEnable();
|
|
|
|
|
2019-10-14 23:34:12 -07:00
|
|
|
// Retrieve the trace buffer
|
2022-12-10 04:35:39 -08:00
|
|
|
const BigBufferHandle perfTraceGetBuffer();
|
2019-10-11 17:43:21 -07:00
|
|
|
|
2019-12-02 16:18:00 -08:00
|
|
|
#if ENABLE_PERF_TRACE
|
2019-10-11 17:43:21 -07:00
|
|
|
class ScopePerf
|
|
|
|
{
|
|
|
|
public:
|
2020-04-29 07:53:35 -07:00
|
|
|
ScopePerf(PE event) : m_event(event) {
|
|
|
|
perfEventBegin(event);
|
2019-10-11 17:43:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
~ScopePerf()
|
|
|
|
{
|
2020-04-29 07:53:35 -07:00
|
|
|
perfEventEnd(m_event);
|
2019-10-11 17:43:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const PE m_event;
|
|
|
|
};
|
2019-12-02 16:18:00 -08:00
|
|
|
|
|
|
|
#else /* if ENABLE_PERF_TRACE */
|
|
|
|
|
|
|
|
struct ScopePerf {
|
2020-04-29 07:53:35 -07:00
|
|
|
ScopePerf(PE) {}
|
2019-12-02 16:18:00 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* ENABLE_PERF_TRACE */
|