]> git.lyx.org Git - features.git/commitdiff
Make pmprof use the correct unit in report
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 5 Mar 2018 09:28:27 +0000 (10:28 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 7 Mar 2018 10:54:40 +0000 (11:54 +0100)
src/support/pmprof.h

index d20d4bb02042e77b566645878273161707180dd8..8f91125f54dc5c5c1d7471aa9e0ea117fd730fa1 100644 (file)
@@ -145,13 +145,24 @@ int gettimeofday(struct timeval * tv, struct timezone * /*tz*/)
 
 namespace {
 
+void dumpTime(long long value)
+{
+       std::cerr << std::fixed << std::setprecision(2);
+       if (value >= 1000000)
+               std::cerr << value / 1000000 << "sec";
+       else if (value >= 1000)
+               std::cerr << value / 1000 << "msec";
+       else
+               std::cerr << value << "usec";
+}
+
 void dump(long long sec, long long usec, unsigned long long count) {
        double const total = sec * 1000000 + usec;
-       std::cerr << std::fixed << std::setprecision(2)
-                         << total / count
-                         << "usec, count=" << count
-                         << ", total=" << total * 0.001 << "msec"
-                         << std::endl;
+       dumpTime(total / count);
+       std::cerr << ", count=" << count
+                         << ", total=";
+       dumpTime(total);
+       std::cerr << std::endl;
 }
 
 } // namespace