Perf trace housekeeping (#1038)

* use default params

* fix that mess

* format
This commit is contained in:
Matthew Kennedy 2019-12-02 16:18:00 -08:00 committed by rusefi
parent d27b8fe080
commit 3c9c9e028c
2 changed files with 17 additions and 25 deletions

View File

@ -855,22 +855,20 @@ int tunerStudioHandleCrcCommand(ts_channel_s *tsChannel, char *data, int incomin
}
break;
case TS_PERF_TRACE_BEGIN:
#endif /* EFI_TOOTH_LOGGER */
#if ENABLE_PERF_TRACE
case TS_PERF_TRACE_BEGIN:
perfTraceEnable();
sendOkResponse(tsChannel, TS_CRC);
#endif /* ENABLE_PERF_TRACE */
break;
case TS_PERF_TRACE_GET_BUFFER:
{
#if ENABLE_PERF_TRACE
auto trace = perfTraceGetBuffer();
sr5SendResponse(tsChannel, TS_CRC, trace.Buffer, trace.Size);
#endif /* ENABLE_PERF_TRACE */
}
#endif /* EFI_TOOTH_LOGGER */
break;
#endif /* ENABLE_PERF_TRACE */
default:
tunerStudioError("ERROR: ignoring unexpected command");
return false;

View File

@ -58,21 +58,9 @@ enum class PE : uint8_t {
// please note that the tool requires a comma at the end of last value
};
void perfEventBegin(PE event, uint8_t data);
void perfEventEnd(PE event, uint8_t data);
void perfEventInstantGlobal(PE event, uint8_t data);
inline void perfEventBegin(PE event) {
perfEventBegin(event, 0);
}
inline void perfEventEnd(PE event) {
perfEventEnd(event, 0);
}
inline void perfEventInstantGlobal(PE event) {
perfEventInstantGlobal(event, 0);
}
void perfEventBegin(PE event, uint8_t data = 0);
void perfEventEnd(PE event, uint8_t data = 0);
void perfEventInstantGlobal(PE event, uint8_t data = 0);
// Enable one buffer's worth of perf tracing, and retrieve the buffer size in bytes
void perfTraceEnable();
@ -86,6 +74,7 @@ struct TraceBufferResult
// Retrieve the trace buffer
const TraceBufferResult perfTraceGetBuffer();
#if ENABLE_PERF_TRACE
class ScopePerf
{
public:
@ -93,19 +82,24 @@ public:
ScopePerf(PE event, uint8_t data) : m_event(event), m_data(data)
{
#if ENABLE_PERF_TRACE
perfEventBegin(event, data);
#endif /* ENABLE_PERF_TRACE */
}
~ScopePerf()
{
#if ENABLE_PERF_TRACE
perfEventEnd(m_event, m_data);
#endif /* ENABLE_PERF_TRACE */
}
private:
const PE m_event;
const uint8_t m_data;
};
#else /* if ENABLE_PERF_TRACE */
struct ScopePerf {
ScopePerf(PE event) { (void)event; }
ScopePerf(PE event, uint8_t data) { (void)event; (void)data; }
};
#endif /* ENABLE_PERF_TRACE */