From 34c8911c90883b55be1fc63b08b0ad3fd1ca3446 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Mon, 5 Aug 2019 12:53:13 +0900 Subject: [PATCH] [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 --- tests/tools/tflite_benchmark/src/tflite_benchmark.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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; -- 2.7.4