mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-11 06:11:37 +08:00
hrt: Add interface functions for latency counters
Add interface functions for fetching latency buckets and counters and use those in perf_counter.cpp. This cleans up the usage of perf counters and enables implementing kernel-userspace interface for those for nuttx protected/kernel build. Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
+29
-1
@@ -208,8 +208,36 @@ static inline void px4_lockstep_progress(int component) { }
|
||||
static inline void px4_lockstep_wait_for_components(void) { }
|
||||
#endif /* defined(ENABLE_LOCKSTEP_SCHEDULER) */
|
||||
|
||||
__END_DECLS
|
||||
|
||||
/* Latency counter functions */
|
||||
|
||||
static inline uint16_t get_latency_bucket_count(void) { return LATENCY_BUCKET_COUNT; }
|
||||
|
||||
#if defined(CONFIG_BUILD_FLAT) || !defined(__PX4_NUTTX)
|
||||
|
||||
static inline latency_info_t get_latency(uint16_t bucket_idx, uint16_t counter_idx)
|
||||
{
|
||||
latency_info_t ret = {latency_buckets[bucket_idx], latency_counters[counter_idx]};
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void reset_latency_counters(void)
|
||||
{
|
||||
for (int i = 0; i <= get_latency_bucket_count(); i++) {
|
||||
latency_counters[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* NuttX protected/kernel build interface functions */
|
||||
|
||||
latency_info_t get_latency(uint16_t bucket_idx, uint16_t counter_idx);
|
||||
void reset_latency_counters(void);
|
||||
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user