mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
perf_counter: added perf_reset() and perf_reset_all() calls
useful for watching counters after system reaches stable flight
This commit is contained in:
parent
cc74874d7e
commit
f4da4bb8ca
@ -218,6 +218,40 @@ perf_end(perf_counter_t handle)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
perf_reset(perf_counter_t handle)
|
||||
{
|
||||
if (handle == NULL)
|
||||
return;
|
||||
|
||||
switch (handle->type) {
|
||||
case PC_COUNT:
|
||||
((struct perf_ctr_count *)handle)->event_count = 0;
|
||||
break;
|
||||
|
||||
case PC_ELAPSED: {
|
||||
struct perf_ctr_elapsed *pce = (struct perf_ctr_elapsed *)handle;
|
||||
pce->event_count = 0;
|
||||
pce->time_start = 0;
|
||||
pce->time_total = 0;
|
||||
pce->time_least = 0;
|
||||
pce->time_most = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case PC_INTERVAL: {
|
||||
struct perf_ctr_interval *pci = (struct perf_ctr_interval *)handle;
|
||||
pci->event_count = 0;
|
||||
pci->time_event = 0;
|
||||
pci->time_first = 0;
|
||||
pci->time_last = 0;
|
||||
pci->time_least = 0;
|
||||
pci->time_most = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
perf_print_counter(perf_counter_t handle)
|
||||
{
|
||||
@ -270,3 +304,14 @@ perf_print_all(void)
|
||||
handle = (perf_counter_t)sq_next(&handle->link);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
perf_reset_all(void)
|
||||
{
|
||||
perf_counter_t handle = (perf_counter_t)sq_peek(&perf_counters);
|
||||
|
||||
while (handle != NULL) {
|
||||
perf_reset(handle);
|
||||
handle = (perf_counter_t)sq_next(&handle->link);
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,6 +97,14 @@ __EXPORT extern void perf_begin(perf_counter_t handle);
|
||||
*/
|
||||
__EXPORT extern void perf_end(perf_counter_t handle);
|
||||
|
||||
/**
|
||||
* Reset a performance event.
|
||||
*
|
||||
* This call resets performance counter to initial state
|
||||
*
|
||||
* @param handle The handle returned from perf_alloc.
|
||||
*/
|
||||
__EXPORT extern void perf_reset(perf_counter_t handle);
|
||||
|
||||
/**
|
||||
* Print one performance counter.
|
||||
@ -110,6 +118,11 @@ __EXPORT extern void perf_print_counter(perf_counter_t handle);
|
||||
*/
|
||||
__EXPORT extern void perf_print_all(void);
|
||||
|
||||
/**
|
||||
* Reset all of the performance counters.
|
||||
*/
|
||||
__EXPORT extern void perf_reset_all(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user