forked from Archive/PX4-Autopilot
perf: removed dprintf from perf library
* Removed dprintf from perf library since it is only ever used with fd=1 (STDOUT) so moved to PX4_INFO_RAW instead. This helps with some platforms (e.g. Qurt) which have some Posix support but not full Posix support.
This commit is contained in:
parent
5edbc2f80a
commit
fa74ee3d5b
|
@ -2,3 +2,4 @@ CONFIG_PLATFORM_POSIX=y
|
|||
CONFIG_BOARD_LINUX=y
|
||||
CONFIG_BOARD_TOOLCHAIN="aarch64-linux-gnu"
|
||||
CONFIG_MODULES_MUORB_APPS=y
|
||||
CONFIG_SYSTEMCMDS_PERF=y
|
||||
|
|
|
@ -419,35 +419,25 @@ perf_print_counter(perf_counter_t handle)
|
|||
return;
|
||||
}
|
||||
|
||||
perf_print_counter_fd(1, handle);
|
||||
}
|
||||
|
||||
void
|
||||
perf_print_counter_fd(int fd, perf_counter_t handle)
|
||||
{
|
||||
if (handle == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (handle->type) {
|
||||
case PC_COUNT:
|
||||
dprintf(fd, "%s: %" PRIu64 " events\n",
|
||||
handle->name,
|
||||
((struct perf_ctr_count *)handle)->event_count);
|
||||
PX4_INFO_RAW("%s: %" PRIu64 " events\n",
|
||||
handle->name,
|
||||
((struct perf_ctr_count *)handle)->event_count);
|
||||
break;
|
||||
|
||||
case PC_ELAPSED: {
|
||||
struct perf_ctr_elapsed *pce = (struct perf_ctr_elapsed *)handle;
|
||||
float rms = sqrtf(pce->M2 / (pce->event_count - 1));
|
||||
dprintf(fd, "%s: %" PRIu64 " events, %" PRIu64 "us elapsed, %.2fus avg, min %" PRIu32 "us max %" PRIu32
|
||||
"us %5.3fus rms\n",
|
||||
handle->name,
|
||||
pce->event_count,
|
||||
pce->time_total,
|
||||
(pce->event_count == 0) ? 0 : (double)pce->time_total / (double)pce->event_count,
|
||||
pce->time_least,
|
||||
pce->time_most,
|
||||
(double)(1e6f * rms));
|
||||
PX4_INFO_RAW("%s: %" PRIu64 " events, %" PRIu64 "us elapsed, %.2fus avg, min %" PRIu32 "us max %" PRIu32
|
||||
"us %5.3fus rms\n",
|
||||
handle->name,
|
||||
pce->event_count,
|
||||
pce->time_total,
|
||||
(pce->event_count == 0) ? 0 : (double)pce->time_total / (double)pce->event_count,
|
||||
pce->time_least,
|
||||
pce->time_most,
|
||||
(double)(1e6f * rms));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -455,13 +445,13 @@ perf_print_counter_fd(int fd, perf_counter_t handle)
|
|||
struct perf_ctr_interval *pci = (struct perf_ctr_interval *)handle;
|
||||
float rms = sqrtf(pci->M2 / (pci->event_count - 1));
|
||||
|
||||
dprintf(fd, "%s: %" PRIu64 " events, %.2fus avg, min %" PRIu32 "us max %" PRIu32 "us %5.3fus rms\n",
|
||||
handle->name,
|
||||
pci->event_count,
|
||||
(pci->event_count == 0) ? 0 : (double)(pci->time_last - pci->time_first) / (double)pci->event_count,
|
||||
pci->time_least,
|
||||
pci->time_most,
|
||||
(double)(1e6f * rms));
|
||||
PX4_INFO_RAW("%s: %" PRIu64 " events, %.2fus avg, min %" PRIu32 "us max %" PRIu32 "us %5.3fus rms\n",
|
||||
handle->name,
|
||||
pci->event_count,
|
||||
(pci->event_count == 0) ? 0 : (double)(pci->time_last - pci->time_first) / (double)pci->event_count,
|
||||
pci->time_least,
|
||||
pci->time_most,
|
||||
(double)(1e6f * rms));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -593,13 +583,13 @@ perf_iterate_all(perf_callback cb, void *user)
|
|||
}
|
||||
|
||||
void
|
||||
perf_print_all(int fd)
|
||||
perf_print_all(void)
|
||||
{
|
||||
pthread_mutex_lock(&perf_counters_mutex);
|
||||
perf_counter_t handle = (perf_counter_t)sq_peek(&perf_counters);
|
||||
|
||||
while (handle != nullptr) {
|
||||
perf_print_counter_fd(fd, handle);
|
||||
perf_print_counter(handle);
|
||||
handle = (perf_counter_t)sq_next(&handle->link);
|
||||
}
|
||||
|
||||
|
@ -607,19 +597,19 @@ perf_print_all(int fd)
|
|||
}
|
||||
|
||||
void
|
||||
perf_print_latency(int fd)
|
||||
perf_print_latency(void)
|
||||
{
|
||||
latency_info_t latency;
|
||||
dprintf(fd, "bucket [us] : events\n");
|
||||
PX4_INFO_RAW("bucket [us] : events\n");
|
||||
|
||||
for (int i = 0; i < get_latency_bucket_count(); i++) {
|
||||
latency = get_latency(i, i);
|
||||
dprintf(fd, " %4i : %li\n", latency.bucket, (long int)latency.counter);
|
||||
PX4_INFO_RAW(" %4i : %li\n", latency.bucket, (long int)latency.counter);
|
||||
}
|
||||
|
||||
// print the overflow bucket value
|
||||
latency = get_latency(get_latency_bucket_count() - 1, get_latency_bucket_count());
|
||||
dprintf(fd, " >%4" PRIu16 " : %" PRIu32 "\n", latency.bucket, latency.counter);
|
||||
PX4_INFO_RAW(" >%4" PRIu16 " : %" PRIu32 "\n", latency.bucket, latency.counter);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -174,14 +174,6 @@ __EXPORT extern void perf_reset(perf_counter_t handle);
|
|||
*/
|
||||
__EXPORT extern void perf_print_counter(perf_counter_t handle);
|
||||
|
||||
/**
|
||||
* Print one performance counter to a fd.
|
||||
*
|
||||
* @param fd File descriptor to print to - e.g. 0 for stdout
|
||||
* @param handle The counter to print.
|
||||
*/
|
||||
__EXPORT extern void perf_print_counter_fd(int fd, perf_counter_t handle);
|
||||
|
||||
/**
|
||||
* Print one performance counter to a buffer.
|
||||
*
|
||||
|
@ -194,10 +186,8 @@ __EXPORT extern int perf_print_counter_buffer(char *buffer, int length, perf_co
|
|||
|
||||
/**
|
||||
* Print all of the performance counters.
|
||||
*
|
||||
* @param fd File descriptor to print to - e.g. 0 for stdout
|
||||
*/
|
||||
__EXPORT extern void perf_print_all(int fd);
|
||||
__EXPORT extern void perf_print_all(void);
|
||||
|
||||
|
||||
typedef void (*perf_callback)(perf_counter_t handle, void *user);
|
||||
|
@ -216,10 +206,8 @@ __EXPORT extern void perf_iterate_all(perf_callback cb, void *user);
|
|||
|
||||
/**
|
||||
* Print hrt latency counters.
|
||||
*
|
||||
* @param fd File descriptor to print to - e.g. 0 for stdout
|
||||
*/
|
||||
__EXPORT extern void perf_print_latency(int fd);
|
||||
__EXPORT extern void perf_print_latency(void);
|
||||
|
||||
/**
|
||||
* Reset all of the performance counters.
|
||||
|
|
|
@ -60,7 +60,7 @@ extern "C" __EXPORT int perf_main(int argc, char *argv[])
|
|||
return 0;
|
||||
|
||||
} else if (strcmp(argv[1], "latency") == 0) {
|
||||
perf_print_latency(1 /* stdout */);
|
||||
perf_print_latency();
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ extern "C" __EXPORT int perf_main(int argc, char *argv[])
|
|||
return -1;
|
||||
}
|
||||
|
||||
perf_print_all(1 /* stdout */);
|
||||
perf_print_all();
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue