[xtrace] Hoist loop invariant code (#6566)
author이한종/On-Device Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>
Wed, 14 Aug 2019 00:45:11 +0000 (09:45 +0900)
committer오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Wed, 14 Aug 2019 00:45:11 +0000 (09:45 +0900)
Hoist loop invariant code in `benchmark_runner.cc` for readability.

Signed-off-by: Hanjoung Lee <hanjoung.lee@samsung.com>
runtimes/contrib/xtrace/src/benchmark_runner.cc

index 72cbef0..1567599 100644 (file)
@@ -65,23 +65,23 @@ void BMRunner<TFL_NNAPI_DELEGATE>::run(const std::string &filename) const
 
   auto sess = std::make_shared<nnfw::tflite::NNAPISession>(interp.release());
 
+  auto get_iteration_count = [](const BMPhase &phase) {
+    switch (phase)
+    {
+      case Warmup:
+        return 1; // Allow configuration
+      case Stable:
+        return 3;
+      default:
+        break;
+    }
+
+    throw std::runtime_error{"Error!"};
+  };
+
   // Iteration!
   for (auto phase : {Warmup, Stable})
   {
-    auto get_iteration_count = [](const BMPhase &phase) {
-      switch (phase)
-      {
-        case Warmup:
-          return 1; // Allow configuration
-        case Stable:
-          return 3;
-        default:
-          break;
-      }
-
-      throw std::runtime_error{"Error!"};
-    };
-
     uint32_t iteration_count = get_iteration_count(phase);
 
     for (uint32_t n = 0; n < iteration_count; ++n)