From: Tae-Young Chung Date: Mon, 22 Apr 2024 01:39:24 +0000 (+0900) Subject: [WIP-04] Add timer X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fa88d15507fe23ca5a5d0e534d8ed0e5edccbc28;p=platform%2Fcore%2Fapi%2Fsingleo.git [WIP-04] Add timer Signed-off-by: Tae-Young Chung --- diff --git a/inference/backends/mediavision/src/MvFaceDetectionTask.cpp b/inference/backends/mediavision/src/MvFaceDetectionTask.cpp index 6d66755..672fa67 100644 --- a/inference/backends/mediavision/src/MvFaceDetectionTask.cpp +++ b/inference/backends/mediavision/src/MvFaceDetectionTask.cpp @@ -16,6 +16,7 @@ #include #include "MvFaceDetectionTask.h" +#include "SingleoTimer.h" using namespace std; @@ -54,6 +55,7 @@ FaceResult& MvFaceDetectionTask::handle(unsigned char* data, unsigned int width, { SINGLEO_LOGD("MvFaceDetectionTask::handle()"); + Timer timer; int ret = mv_source_fill_by_buffer(_mv_src, data, width * height * byte_per_pixel, width, height, MEDIA_VISION_COLORSPACE_RGB888); if (ret != MEDIA_VISION_ERROR_NONE) @@ -79,8 +81,8 @@ FaceResult& MvFaceDetectionTask::handle(unsigned char* data, unsigned int width, result._rects.push_back(rect); SINGLEO_LOGD("idx[%2zd]: (%3zd, %3zd, %3zd, %3zd)", idx, rect.left, rect.top, rect.right, rect.bottom); } + SINGLEO_LOGD("MvFaceDectectionTask::handle() takes %d ms", timer.check_ms()); result = MvFaceTaskManager::handle(data, width, height, byte_per_pixel, result); - return result; } diff --git a/inference/backends/mediavision/src/MvFaceLandmarkDetectionTask.cpp b/inference/backends/mediavision/src/MvFaceLandmarkDetectionTask.cpp index 08dc8dd..d87de1d 100644 --- a/inference/backends/mediavision/src/MvFaceLandmarkDetectionTask.cpp +++ b/inference/backends/mediavision/src/MvFaceLandmarkDetectionTask.cpp @@ -17,6 +17,7 @@ #include #include #include "MvFaceLandmarkDetectionTask.h" +#include "SingleoTimer.h" using namespace std; @@ -55,6 +56,7 @@ FaceResult& MvFaceLandmarkDetectionTask::handle(unsigned char* data, unsigned in { SINGLEO_LOGD("MvFaceLandmarkDetectionTask::handle()"); + Timer timer; cv::Mat cvData(cv::Size(width, height), CV_MAKE_TYPE(CV_8U, byte_per_pixel), data); cv::Mat roiCvData; @@ -97,6 +99,7 @@ FaceResult& MvFaceLandmarkDetectionTask::handle(unsigned char* data, unsigned in result = MvFaceTaskManager::handle(data, width, height, byte_per_pixel, result); } } + SINGLEO_LOGD("MvFaceLandmarkDetectionTask::handle() takes %d ms", timer.check_ms()); return result; } diff --git a/log/include/SingleoTimer.h b/log/include/SingleoTimer.h new file mode 100644 index 0000000..558ee77 --- /dev/null +++ b/log/include/SingleoTimer.h @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __SINGLEO_TIME_H__ +#define __SINGLEO_TIME_H__ + +#include + +using namespace std; + +class Timer { +private: + chrono::system_clock::time_point _start; + +public: + Timer() { + _start = chrono::system_clock::now(); + } + void reset() { + _start = chrono::system_clock::now(); + } + int64_t check_ms() { + return chrono::duration_cast(chrono::system_clock::now() - _start).count(); + } +}; +#endif