mirror of
https://github.com/openmv/openmv.git
synced 2025-09-26 23:09:13 +08:00
common/profiler: Add get_size function.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit is contained in:
parent
0dbb5c8aa7
commit
49f330f2dc
@ -149,8 +149,11 @@ mutex_t *omv_profiler_lock(void) {
|
||||
return &profiler.mutex;
|
||||
}
|
||||
|
||||
void *omv_profiler_get_data(size_t *count) {
|
||||
*count = profiler.pool_index;
|
||||
size_t omv_profiler_get_size(void) {
|
||||
return profiler.pool_index * sizeof(omv_profiler_data_t);
|
||||
}
|
||||
|
||||
const void *omv_profiler_get_data(void) {
|
||||
return profiler.pool;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,8 @@ typedef struct __attribute__((packed)) _prof_data {
|
||||
|
||||
OMV_ATTR_NO_INSTRUMENT void omv_profiler_init(void);
|
||||
OMV_ATTR_NO_INSTRUMENT void omv_profiler_reset(void);
|
||||
OMV_ATTR_NO_INSTRUMENT void *omv_profiler_get_data(size_t *count);
|
||||
OMV_ATTR_NO_INSTRUMENT size_t omv_profiler_get_size(void);
|
||||
OMV_ATTR_NO_INSTRUMENT const void *omv_profiler_get_data(void);
|
||||
OMV_ATTR_NO_INSTRUMENT void omv_profiler_set_mode(uint32_t mode);
|
||||
OMV_ATTR_NO_INSTRUMENT void omv_profiler_set_event(uint32_t num, uint32_t type);
|
||||
#ifndef __cplusplus
|
||||
|
@ -287,10 +287,8 @@ void usbdbg_data_in(uint32_t size, usbdbg_write_callback_t write_callback) {
|
||||
uint32_t buffer[3] = { 0 };
|
||||
#if OMV_PROFILER_ENABLE
|
||||
if (mutex_try_lock(omv_profiler_lock(), MUTEX_TID_IDE)) {
|
||||
size_t count = 0;
|
||||
(void) omv_profiler_get_data(&count);
|
||||
|
||||
buffer[0] = count;
|
||||
size_t size = omv_profiler_get_size();
|
||||
buffer[0] = size / sizeof(omv_profiler_data_t);
|
||||
buffer[1] = sizeof(omv_profiler_data_t);
|
||||
buffer[2] = __PMU_NUM_EVENTCNT;
|
||||
}
|
||||
@ -303,9 +301,7 @@ void usbdbg_data_in(uint32_t size, usbdbg_write_callback_t write_callback) {
|
||||
#if OMV_PROFILER_ENABLE
|
||||
case USBDBG_PROFILE_DUMP:
|
||||
if (xfer_offs < xfer_size) {
|
||||
size_t count = 0;
|
||||
char *data = omv_profiler_get_data(&count);
|
||||
|
||||
const char *data = omv_profiler_get_data();
|
||||
write_callback(data + xfer_offs, size);
|
||||
xfer_offs += size;
|
||||
if (xfer_offs == xfer_size) {
|
||||
|
Loading…
Reference in New Issue
Block a user