From 97d8530b7e9bf1e3f4c7f7ca2ed05c3238222235 Mon Sep 17 00:00:00 2001 From: Dan Nechita Date: Wed, 17 Apr 2024 15:12:43 +0300 Subject: [PATCH] sdk: Time profile waiting for v4l2 buffer within processBuffer() Signed-off-by: Dan Nechita --- .../connections/target/buffer_processor.cpp | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/sdk/src/connections/target/buffer_processor.cpp b/sdk/src/connections/target/buffer_processor.cpp index c3bd0cef0..a5fcfea6f 100644 --- a/sdk/src/connections/target/buffer_processor.cpp +++ b/sdk/src/connections/target/buffer_processor.cpp @@ -226,8 +226,13 @@ aditof::Status BufferProcessor::processBuffer(uint16_t *buffer = nullptr) { uint8_t *pdata; dev = m_inputVideoDev; uint8_t *pdata_user_space = nullptr; - +#ifdef TIME_PROFILING + steady_clock::time_point wfb_t0 = steady_clock::now(); +#endif status = waitForBufferPrivate(dev); +#ifdef TIME_PROFILING + steady_clock::time_point wfb_t1 = steady_clock::now(); +#endif if (status != Status::OK) { return status; } @@ -317,17 +322,27 @@ aditof::Status BufferProcessor::processBuffer(uint16_t *buffer = nullptr) { // Measure execution times, display statistics auto process_buffer_elapsed_time = std::chrono::duration_cast(pb_t1 - pb_t0); + auto wait_for_buffer_elapsed_time = + std::chrono::duration_cast(wfb_t1 - wfb_t0); auto tofi_compute_elapsed_time = std::chrono::duration_cast(tc_t1 - tc_t0); auto frame_memcpy_elapsed_time = std::chrono::duration_cast(mc_t1 - mc_t0); - auto total_profiled_time = - tofi_compute_elapsed_time + frame_memcpy_elapsed_time; + auto total_profiled_time = wait_for_buffer_elapsed_time + + tofi_compute_elapsed_time + + frame_memcpy_elapsed_time; std::cout << std::endl; std::cout << "BufferProcessor::processBuffer() took: " << process_buffer_elapsed_time.count() << "us" << std::endl; + std::cout << "|--> WaitForBuffer() took: " + << wait_for_buffer_elapsed_time.count() << "us" + << "(" + << ((double)wait_for_buffer_elapsed_time.count() / + process_buffer_elapsed_time.count()) * + 100.0 + << "%)" << std::endl; std::cout << "|--> TofiCompute() took: " << tofi_compute_elapsed_time.count() << "us" << "("