From: 박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 Date: Mon, 5 Aug 2019 03:53:13 +0000 (+0900) Subject: [tflite_benchmark] Insert pause between iterations (#6189) X-Git-Tag: submit/tizen/20190809.050447~194 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=34c8911c90883b55be1fc63b08b0ad3fd1ca3446;p=platform%2Fcore%2Fml%2Fnnfw.git [tflite_benchmark] Insert pause between iterations (#6189) tflite_benchmark now allows users to insert pause between iterations via "PAUSE" environment variable. Signed-off-by: Jonghyun Park --- diff --git a/tests/tools/tflite_benchmark/src/tflite_benchmark.cc b/tests/tools/tflite_benchmark/src/tflite_benchmark.cc index 27ef2cb..54c97c4 100644 --- a/tests/tools/tflite_benchmark/src/tflite_benchmark.cc +++ b/tests/tools/tflite_benchmark/src/tflite_benchmark.cc @@ -30,7 +30,9 @@ #include #include +#include #include +#include #include "misc/environment.h" #include "misc/benchmark.h" @@ -70,6 +72,7 @@ int main(const int argc, char **argv) const bool use_nnapi = nnfw::misc::get_env_bool("USE_NNAPI"); const auto thread_count = nnfw::misc::get_env_int("THREAD", -1); + const auto pause = nnfw::misc::get_env_int("PAUSE", 0); std::cout << "Num threads: " << thread_count << std::endl; if (use_nnapi) @@ -77,6 +80,12 @@ int main(const int argc, char **argv) std::cout << "Use NNAPI" << std::endl; } + assert(pause >= 0); + if (pause > 0) + { + std::cout << "Insert " << pause << "s pause between iterations" << std::endl; + } + StderrReporter error_reporter; auto model = FlatBufferModel::BuildFromFile(filename, &error_reporter); @@ -228,6 +237,12 @@ int main(const int argc, char **argv) acc(elapsed.count()); std::cout << "Iteration " << n << ": " << elapsed.count() << "ms" << std::endl; + + // Insert "pause" + if ((n != cnt - 1) && (pause > 0)) + { + std::this_thread::sleep_for(std::chrono::seconds(pause)); + } } std::cout << "--------" << std::endl;