Fix unit reported by TimeTaker (was always ms)
authorKahrl <kahrl@gmx.net>
Thu, 9 Oct 2014 09:15:03 +0000 (11:15 +0200)
committerKahrl <kahrl@gmx.net>
Thu, 9 Oct 2014 09:15:03 +0000 (11:15 +0200)
src/util/timetaker.cpp

index 720a9e1a976e4a78ff1919caa08a74156f2ed776..dcf07dc0d02f35df6912a6245fe269227b76f152 100644 (file)
@@ -44,8 +44,17 @@ u32 TimeTaker::stop(bool quiet)
                }
                else
                {
-                       if(quiet == false)
-                               infostream<<m_name<<" took "<<dtime<<"ms"<<std::endl;
+                       if (!quiet) {
+                               static const char* const units[] = {
+                                       "s"  /* PRECISION_SECONDS */,
+                                       "ms" /* PRECISION_MILLI */,
+                                       "us" /* PRECISION_MICRO */,
+                                       "ns" /* PRECISION_NANO */,
+                               };
+                               infostream << m_name << " took "
+                                          << dtime << units[m_precision]
+                                          << std::endl;
+                       }
                }
                m_running = false;
                return dtime;