Perf trace housekeeping (#1038)
* use default params * fix that mess * format
This commit is contained in:
parent
3f0385f70d
commit
2bedb3ad8c
|
@ -855,22 +855,20 @@ int tunerStudioHandleCrcCommand(ts_channel_s *tsChannel, char *data, int incomin
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case TS_PERF_TRACE_BEGIN:
|
#endif /* EFI_TOOTH_LOGGER */
|
||||||
#if ENABLE_PERF_TRACE
|
#if ENABLE_PERF_TRACE
|
||||||
|
case TS_PERF_TRACE_BEGIN:
|
||||||
perfTraceEnable();
|
perfTraceEnable();
|
||||||
sendOkResponse(tsChannel, TS_CRC);
|
sendOkResponse(tsChannel, TS_CRC);
|
||||||
|
|
||||||
#endif /* ENABLE_PERF_TRACE */
|
|
||||||
break;
|
break;
|
||||||
case TS_PERF_TRACE_GET_BUFFER:
|
case TS_PERF_TRACE_GET_BUFFER:
|
||||||
{
|
{
|
||||||
#if ENABLE_PERF_TRACE
|
|
||||||
auto trace = perfTraceGetBuffer();
|
auto trace = perfTraceGetBuffer();
|
||||||
sr5SendResponse(tsChannel, TS_CRC, trace.Buffer, trace.Size);
|
sr5SendResponse(tsChannel, TS_CRC, trace.Buffer, trace.Size);
|
||||||
#endif /* ENABLE_PERF_TRACE */
|
|
||||||
}
|
}
|
||||||
#endif /* EFI_TOOTH_LOGGER */
|
|
||||||
break;
|
break;
|
||||||
|
#endif /* ENABLE_PERF_TRACE */
|
||||||
default:
|
default:
|
||||||
tunerStudioError("ERROR: ignoring unexpected command");
|
tunerStudioError("ERROR: ignoring unexpected command");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -58,21 +58,9 @@ enum class PE : uint8_t {
|
||||||
// please note that the tool requires a comma at the end of last value
|
// please note that the tool requires a comma at the end of last value
|
||||||
};
|
};
|
||||||
|
|
||||||
void perfEventBegin(PE event, uint8_t data);
|
void perfEventBegin(PE event, uint8_t data = 0);
|
||||||
void perfEventEnd(PE event, uint8_t data);
|
void perfEventEnd(PE event, uint8_t data = 0);
|
||||||
void perfEventInstantGlobal(PE event, uint8_t data);
|
void perfEventInstantGlobal(PE event, uint8_t data = 0);
|
||||||
|
|
||||||
inline void perfEventBegin(PE event) {
|
|
||||||
perfEventBegin(event, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void perfEventEnd(PE event) {
|
|
||||||
perfEventEnd(event, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void perfEventInstantGlobal(PE event) {
|
|
||||||
perfEventInstantGlobal(event, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enable one buffer's worth of perf tracing, and retrieve the buffer size in bytes
|
// Enable one buffer's worth of perf tracing, and retrieve the buffer size in bytes
|
||||||
void perfTraceEnable();
|
void perfTraceEnable();
|
||||||
|
@ -86,6 +74,7 @@ struct TraceBufferResult
|
||||||
// Retrieve the trace buffer
|
// Retrieve the trace buffer
|
||||||
const TraceBufferResult perfTraceGetBuffer();
|
const TraceBufferResult perfTraceGetBuffer();
|
||||||
|
|
||||||
|
#if ENABLE_PERF_TRACE
|
||||||
class ScopePerf
|
class ScopePerf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -93,19 +82,24 @@ public:
|
||||||
|
|
||||||
ScopePerf(PE event, uint8_t data) : m_event(event), m_data(data)
|
ScopePerf(PE event, uint8_t data) : m_event(event), m_data(data)
|
||||||
{
|
{
|
||||||
#if ENABLE_PERF_TRACE
|
|
||||||
perfEventBegin(event, data);
|
perfEventBegin(event, data);
|
||||||
#endif /* ENABLE_PERF_TRACE */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~ScopePerf()
|
~ScopePerf()
|
||||||
{
|
{
|
||||||
#if ENABLE_PERF_TRACE
|
|
||||||
perfEventEnd(m_event, m_data);
|
perfEventEnd(m_event, m_data);
|
||||||
#endif /* ENABLE_PERF_TRACE */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const PE m_event;
|
const PE m_event;
|
||||||
const uint8_t m_data;
|
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 */
|
||||||
|
|
Loading…
Reference in New Issue