tflite_benchmark: get env refactor (#1801)
authorVitaliy Cherepanov/AI Tools Lab /SRR/Engineer/삼성전자 <v.cherepanov@samsung.com>
Tue, 3 Jul 2018 23:54:18 +0000 (02:54 +0300)
committer박세희/동작제어Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Tue, 3 Jul 2018 23:54:18 +0000 (08:54 +0900)
* tflite_benchmark: get env refactor

using nnfw::util::get_env_int instead of custom get_env call

Signed-off-by: Vitaliy Cherepanov <v.cherepanov@samsung.com>
* add const spec

Signed-off-by: Vitaliy Cherepanov <v.cherepanov@samsung.com>
* fix compare signed/unsigned issue

tools/tflite_benchmark/src/tflite_benchmark.cc

index f20cef3..cfe244e 100644 (file)
 using namespace tflite;
 using namespace tflite::ops::builtin;
 
-class Count
-{
-public:
-  Count() : _value(1)
-  {
-    auto env = std::getenv("COUNT");
-
-    if (env)
-    {
-      _value = atoi(env);
-    }
-  }
-
-public:
-  uint32_t value(void) const { return _value; }
-
-private:
-  uint32_t _value;
-};
-
 void help(std::ostream &out, const int argc, char **argv)
 {
   std::string cmd = argv[0];
@@ -223,13 +203,13 @@ int main(const int argc, char **argv)
   //
   // Measure
   //
-  const Count count;
+  const auto cnt = nnfw::util::get_env_int("COUNT", 1);
 
   using namespace boost::accumulators;
 
   accumulator_set<double, stats<tag::mean, tag::min, tag::max>> acc;
 
-  for (uint32_t n = 0; n < count.value(); ++n)
+  for (int n = 0; n < cnt; ++n)
   {
     std::chrono::milliseconds elapsed(0);