forked from Archive/PX4-Autopilot
commit
72a0a4a71c
|
@ -39,6 +39,7 @@
|
|||
#include <nuttx/config.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "systemlib/perf_counter.h"
|
||||
|
||||
|
@ -63,6 +64,15 @@ __EXPORT int perf_main(int argc, char *argv[]);
|
|||
|
||||
int perf_main(int argc, char *argv[])
|
||||
{
|
||||
if (argc > 1) {
|
||||
if (strcmp(argv[1], "reset") == 0) {
|
||||
perf_reset_all();
|
||||
return 0;
|
||||
}
|
||||
printf("Usage: perf <reset>\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
perf_print_all();
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
|
|
|
@ -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…
Reference in New Issue