From: Jean-Marc Lasgouttes Date: Mon, 5 Mar 2018 09:28:27 +0000 (+0100) Subject: Make pmprof use the correct unit in report X-Git-Tag: lyx-2.4.0dev-acb2ca7b~3741 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=dc2ad4456259bf99c77ae852222738062f607ee8;p=features.git Make pmprof use the correct unit in report --- diff --git a/src/support/pmprof.h b/src/support/pmprof.h index d20d4bb020..8f91125f54 100644 --- a/src/support/pmprof.h +++ b/src/support/pmprof.h @@ -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