From 307d8a99a66d54de9442ebe78883367870aca30e Mon Sep 17 00:00:00 2001 From: Bartosz Meglicki Date: Tue, 9 Jun 2020 20:11:34 +0200 Subject: [PATCH] benchmark alignment time - simple measurment - to get idea about alignment time and total frame processing time Related to #18 --- rnhve_depth_color.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rnhve_depth_color.cpp b/rnhve_depth_color.cpp index c8c2ae1..60f423d 100644 --- a/rnhve_depth_color.cpp +++ b/rnhve_depth_color.cpp @@ -23,6 +23,9 @@ #include #include +//benchmark related +#include //clock_gettime + using namespace std; int hint_user_on_failure(char *argv[]); @@ -91,10 +94,15 @@ bool main_loop(const input_args& input, rs2::pipeline& realsense, nhve *streamer rs2::align aligner( (input.align_to == Color) ? RS2_STREAM_COLOR : RS2_STREAM_DEPTH); + struct timespec start, end, end_all; + for(f = 0; f < frames; ++f) { rs2::frameset frameset = realsense.wait_for_frames(); + clock_gettime(CLOCK_MONOTONIC_RAW, &start); frameset = aligner.process(frameset); + clock_gettime(CLOCK_MONOTONIC_RAW, &end); + rs2::depth_frame depth = frameset.get_depth_frame(); rs2::video_frame color = frameset.get_color_frame(); @@ -125,6 +133,12 @@ bool main_loop(const input_args& input, rs2::pipeline& realsense, nhve *streamer cerr << "failed to send" << endl; break; } + + clock_gettime(CLOCK_MONOTONIC_RAW, &end_all); + double align_ms = (end.tv_nsec - start.tv_nsec) / 1000000.0; + double all_ms = (end_all.tv_nsec - start.tv_nsec) / 1000000.0; + + cout << "aligned in " << align_ms << " ms" << " align + encode + send in " << all_ms << endl; } //flush the streamer by sending NULL frame