mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge pull request #2379 from openmv/profile_macro
misc/common: Fix profiling macro.
This commit is contained in:
commit
b14d315fde
@ -52,12 +52,11 @@
|
||||
#include "py/mphal.h"
|
||||
#define OMV_CONCATENATE_DETAIL(x, y) x##y
|
||||
#define OMV_CONCATENATE(x, y) OMV_CONCATENATE_DETAIL(x, y)
|
||||
|
||||
#define OMV_PROFILE_START(F) mp_uint_t OMV_CONCATENATE(F, _ticks_start_) = mp_hal_ticks_us()
|
||||
#define OMV_PROFILE_END(F) printf("%s %u us\n", F, mp_hal_ticks_us() - OMV_CONCATENATE(F, _ticks_start_))
|
||||
#define OMV_PROFILE_START(F) mp_uint_t OMV_CONCATENATE(_ticks_start_, F) = mp_hal_ticks_us()
|
||||
#define OMV_PROFILE_PRINT(F) printf("%s:%s %u us\n", __FUNCTION__, #F, mp_hal_ticks_us() - OMV_CONCATENATE(_ticks_start_, F))
|
||||
#else
|
||||
#define OMV_PROFILE_START(F)
|
||||
#define OMV_PROFILE_END(F)
|
||||
#define OMV_PROFILE_PRINT(F)
|
||||
#endif
|
||||
|
||||
#endif //__OMV_COMMON_H__
|
||||
|
||||
@ -2843,7 +2843,7 @@ void imlib_draw_image(image_t *dst_img,
|
||||
imlib_draw_row_callback_t callback,
|
||||
void *callback_arg,
|
||||
void *dst_row_override) {
|
||||
OMV_PROFILE_START(__FUNCTION__);
|
||||
OMV_PROFILE_START();
|
||||
int dst_delta_x = 1; // positive direction
|
||||
if (x_scale < 0.f) {
|
||||
// flip X
|
||||
@ -5518,7 +5518,7 @@ exit_cleanup:
|
||||
if (&new_src_img == src_img) {
|
||||
fb_free();
|
||||
}
|
||||
OMV_PROFILE_END(__FUNCTION__);
|
||||
OMV_PROFILE_PRINT();
|
||||
}
|
||||
|
||||
#ifdef IMLIB_ENABLE_FLOOD_FILL
|
||||
|
||||
@ -2841,7 +2841,7 @@ static int DecodeJPEG(JPEGIMAGE *pJPEG) {
|
||||
}
|
||||
|
||||
void jpeg_decompress(image_t *dst, image_t *src) {
|
||||
OMV_PROFILE_START(__FUNCTION__);
|
||||
OMV_PROFILE_START();
|
||||
JPEGIMAGE jpg;
|
||||
|
||||
// Supports decoding baseline JPEGs only.
|
||||
@ -2882,6 +2882,6 @@ void jpeg_decompress(image_t *dst, image_t *src) {
|
||||
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("JPEG decoder failed."));
|
||||
}
|
||||
|
||||
OMV_PROFILE_END(__FUNCTION__);
|
||||
OMV_PROFILE_PRINT();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1567,7 +1567,7 @@ static void jpeg_write_headers(jpeg_buf_t *jpeg_buf, int w, int h, int bpp, jpeg
|
||||
}
|
||||
|
||||
bool jpeg_compress(image_t *src, image_t *dst, int quality, bool realloc, jpeg_subsampling_t subsampling) {
|
||||
OMV_PROFILE_START(__FUNCTION__);
|
||||
OMV_PROFILE_START();
|
||||
|
||||
if (!dst->data) {
|
||||
uint32_t size = 0;
|
||||
@ -1898,7 +1898,7 @@ bool jpeg_compress(image_t *src, image_t *dst, int quality, bool realloc, jpeg_s
|
||||
dst->size = jpeg_buf.idx;
|
||||
dst->data = jpeg_buf.buf;
|
||||
|
||||
OMV_PROFILE_END(__FUNCTION__);
|
||||
OMV_PROFILE_PRINT();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -105,7 +105,7 @@ unsigned lodepng_convert_cb(unsigned char *out, const unsigned char *in,
|
||||
|
||||
#if defined(IMLIB_ENABLE_PNG_ENCODER)
|
||||
bool png_compress(image_t *src, image_t *dst) {
|
||||
OMV_PROFILE_START(__FUNCTION__);
|
||||
OMV_PROFILE_START();
|
||||
|
||||
if (src->is_compressed) {
|
||||
return true;
|
||||
@ -177,14 +177,14 @@ bool png_compress(image_t *src, image_t *dst) {
|
||||
// free fb_alloc() memory used for umm_init_x().
|
||||
fb_free(); // umm_init_x();
|
||||
}
|
||||
OMV_PROFILE_END(__FUNCTION__);
|
||||
OMV_PROFILE_PRINT();
|
||||
return false;
|
||||
}
|
||||
#endif // IMLIB_ENABLE_PNG_ENCODER
|
||||
|
||||
#if defined(IMLIB_ENABLE_PNG_DECODER)
|
||||
void png_decompress(image_t *dst, image_t *src) {
|
||||
OMV_PROFILE_START(__FUNCTION__);
|
||||
OMV_PROFILE_START();
|
||||
umm_init_x(fb_avail());
|
||||
|
||||
LodePNGState state;
|
||||
@ -226,7 +226,7 @@ void png_decompress(image_t *dst, image_t *src) {
|
||||
|
||||
// free fb_alloc() memory used for umm_init_x().
|
||||
fb_free(); // umm_init_x();
|
||||
OMV_PROFILE_END(__FUNCTION__);
|
||||
OMV_PROFILE_PRINT();
|
||||
}
|
||||
#endif // IMLIB_ENABLE_PNG_DECODER
|
||||
#endif // IMLIB_ENABLE_PNG_ENCODER || IMLIB_ENABLE_PNG_DECODER
|
||||
|
||||
@ -226,8 +226,13 @@ static mp_obj_t py_ml_model_predict(uint n_args, const mp_obj_t *pos_args, mp_ma
|
||||
mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Unsupported input type. Expected a list"));
|
||||
}
|
||||
|
||||
OMV_PROFILE_START(preprocess);
|
||||
py_ml_process_input(model, pos_args[1]);
|
||||
OMV_PROFILE_PRINT(preprocess);
|
||||
|
||||
OMV_PROFILE_START(inference);
|
||||
ml_backend_run_inference(model);
|
||||
OMV_PROFILE_PRINT(inference);
|
||||
|
||||
mp_obj_t output = py_ml_process_output(model);
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ static void jpeg_compress_data_ready(JPEG_HandleTypeDef *hjpeg, uint8_t *pDataOu
|
||||
}
|
||||
|
||||
bool jpeg_compress(image_t *src, image_t *dst, int quality, bool realloc, jpeg_subsampling_t subsampling) {
|
||||
OMV_PROFILE_START(__FUNCTION__);
|
||||
OMV_PROFILE_START();
|
||||
HAL_JPEG_RegisterGetDataCallback(&JPEG_state.jpeg_descr, jpeg_compress_get_data);
|
||||
HAL_JPEG_RegisterDataReadyCallback(&JPEG_state.jpeg_descr, jpeg_compress_data_ready);
|
||||
|
||||
@ -365,7 +365,7 @@ exit_cleanup:
|
||||
|
||||
fb_free(); // mcu_row_buffer (after DMA is aborted)
|
||||
|
||||
OMV_PROFILE_END(__FUNCTION__);
|
||||
OMV_PROFILE_PRINT();
|
||||
return jpeg_overflow;
|
||||
}
|
||||
|
||||
@ -397,7 +397,7 @@ static void jpeg_decompress_data_ready(JPEG_HandleTypeDef *hjpeg, uint8_t *pData
|
||||
}
|
||||
|
||||
void jpeg_decompress(image_t *dst, image_t *src) {
|
||||
OMV_PROFILE_START(__FUNCTION__);
|
||||
OMV_PROFILE_START();
|
||||
|
||||
// Verify the jpeg image is not a non-baseline jpeg image and check that is has
|
||||
// valid headers up to the start-of-scan header (which cannot be trivially walked).
|
||||
@ -752,7 +752,7 @@ exit_cleanup:
|
||||
fb_free(); // JPEG_state.jpeg_descr.pJpegInBuffPtr (after DMA is aborted)
|
||||
}
|
||||
|
||||
OMV_PROFILE_END(__FUNCTION__);
|
||||
OMV_PROFILE_PRINT();
|
||||
}
|
||||
|
||||
void imlib_hardware_jpeg_init() {
|
||||
|
||||
@ -32,7 +32,7 @@ int omv_gpu_draw_image(image_t *src_img,
|
||||
const uint16_t *color_palette,
|
||||
const uint8_t *alpha_palette,
|
||||
image_hint_t hint) {
|
||||
OMV_PROFILE_START(__FUNCTION__);
|
||||
OMV_PROFILE_START();
|
||||
|
||||
// DMA2D can only draw on RGB565 buffers and the destination/source buffers must be accessible by DMA.
|
||||
if ((dst_img->pixfmt != PIXFORMAT_RGB565) || (!DMA_BUFFER(dst_img->data)) || (!DMA_BUFFER(src_img->data))) {
|
||||
@ -211,7 +211,7 @@ int omv_gpu_draw_image(image_t *src_img,
|
||||
fb_free(); // clut
|
||||
}
|
||||
|
||||
OMV_PROFILE_END(__FUNCTION__);
|
||||
OMV_PROFILE_PRINT();
|
||||
return 0;
|
||||
}
|
||||
#endif // (OMV_GPU_ENABLE == 1)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user