From: Inki Dae Date: Wed, 25 Nov 2020 06:48:42 +0000 (+0900) Subject: Use static profiler object instead of dynamic one X-Git-Tag: submit/tizen/20201126.061710^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c521a280ea1c47e585dc30809f5a339d47f4bba;p=platform%2Fcore%2Fmultimedia%2Finference-engine-interface.git Use static profiler object instead of dynamic one Only one profiler object is needed per a inference engine common class so use static profiler object instead of dynamic one. Change-Id: I29980442617aaca6e50b07392c50c74154a3ac29 Signed-off-by: Inki Dae --- diff --git a/include/inference_engine_common_impl.h b/include/inference_engine_common_impl.h index 3af4c6c..0517e79 100644 --- a/include/inference_engine_common_impl.h +++ b/include/inference_engine_common_impl.h @@ -249,7 +249,7 @@ namespace Common inference_backend_type_e mSelectedBackendEngine; // Profiler - InferenceEngineProfiler *mProfiler; + InferenceEngineProfiler mProfiler; // In default, we use profiler. bool mUseProfiler; unsigned int mProfilerDumpType; diff --git a/src/inference_engine_common_impl.cpp b/src/inference_engine_common_impl.cpp index d4d903b..f65c5f3 100644 --- a/src/inference_engine_common_impl.cpp +++ b/src/inference_engine_common_impl.cpp @@ -53,7 +53,6 @@ namespace Common InferenceEngineCommon::InferenceEngineCommon() : mSelectedBackendEngine(INFERENCE_BACKEND_NONE), - mProfiler(), mUseProfiler(false), mProfilerDumpType(IE_PROFILER_DUMP_MIN), mBackendModule(), @@ -69,8 +68,7 @@ namespace Common LOGW("ENTER"); if (mUseProfiler == true) { - mProfiler->Dump(mProfilerDumpType); - delete mProfiler; + mProfiler.Dump(mProfilerDumpType); } LOGW("LEAVE"); @@ -211,8 +209,6 @@ out: mUseProfiler = enable; if (mUseProfiler == true) { - mProfiler = new InferenceEngineProfiler(); - // In default, profile data will be stored to a given file. mProfilerDumpType = IE_PROFILER_DUMP_FILE; } @@ -241,7 +237,7 @@ out: } mProfilerDumpType = IE_PROFILER_DUMP_FILE; - mProfiler->SetDumpFilename(filename); + mProfiler.SetDumpFilename(filename); return INFERENCE_ENGINE_ERROR_NONE; } @@ -321,7 +317,7 @@ out: if (mUseProfiler == true) { // Memory usage will be measured between BindBackend ~ UnbindBackend callbacks. - mProfiler->Start(IE_PROFILER_MEMORY); + mProfiler.Start(IE_PROFILER_MEMORY); } std::string backendLibName = @@ -345,7 +341,7 @@ out: } if (mUseProfiler == true) { - mProfiler->AddBackendName(config->backend_name); + mProfiler.AddBackendName(config->backend_name); } LOGI("LEAVE"); @@ -370,7 +366,7 @@ out: if (mUseProfiler == true) { // Memory usage will be measured between BindBackend ~ UnbindBackend callbacks. - mProfiler->Start(IE_PROFILER_MEMORY); + mProfiler.Start(IE_PROFILER_MEMORY); } std::string backendNameTable[INFERENCE_BACKEND_MAX] = { @@ -390,7 +386,7 @@ out: } if (mUseProfiler == true) { - mProfiler->AddBackendName(backendNameTable[backend_type]); + mProfiler.AddBackendName(backendNameTable[backend_type]); } LOGI("LEAVE"); @@ -404,7 +400,7 @@ out: if (mUseProfiler == true) { // Memory usage will be measured between BindBackend ~ UnbindBackend callbacks. - mProfiler->Stop(IE_PROFILER_MEMORY); + mProfiler.Stop(IE_PROFILER_MEMORY); } if (mBackendModule) { @@ -435,7 +431,7 @@ out: LOGE("Fail to SetTargetDevice"); if (mUseProfiler == true) { - mProfiler->AddTargetDevices(types); + mProfiler.AddTargetDevices(types); } return ret; @@ -449,9 +445,9 @@ out: CHECK_ENGINE_INSTANCE(mBackendHandle); if (mUseProfiler == true) { - mProfiler->AddModelName(model_paths[0]); - mProfiler->PushEnv(); - mProfiler->Start(IE_PROFILER_LATENCY); + mProfiler.AddModelName(model_paths[0]); + mProfiler.PushEnv(); + mProfiler.Start(IE_PROFILER_LATENCY); } int ret = mBackendHandle->Load(model_paths, model_format); @@ -461,7 +457,7 @@ out: } if (mUseProfiler == true) { - mProfiler->Stop(IE_PROFILER_LATENCY, "Load"); + mProfiler.Stop(IE_PROFILER_LATENCY, "Load"); } LOGI("LEAVE"); @@ -611,7 +607,7 @@ out: CHECK_ENGINE_INSTANCE(mBackendHandle); if (mUseProfiler == true) { - mProfiler->Start(IE_PROFILER_LATENCY); + mProfiler.Start(IE_PROFILER_LATENCY); } int ret = mBackendHandle->Run(input_buffers, output_buffers); @@ -621,7 +617,7 @@ out: } if (mUseProfiler == true) { - mProfiler->Stop(IE_PROFILER_LATENCY, "Run"); + mProfiler.Stop(IE_PROFILER_LATENCY, "Run"); } return ret;