From 45db15e51be05f000d52e52b03a24ced1e1496ac Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 27 Nov 2017 11:38:15 -0500 Subject: Increase precision of cpb When cpb is less than 24 or so print two decimal places --- bench1.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'bench1.cpp') diff --git a/bench1.cpp b/bench1.cpp index 510cd81c..b4f7263d 100644 --- a/bench1.cpp +++ b/bench1.cpp @@ -63,7 +63,13 @@ void OutputResultBytes(const char *name, double length, double timeTaken) std::cout << std::setiosflags(std::ios::fixed); std::cout << "" << std::setprecision(0) << std::setiosflags(std::ios::fixed) << mbs; if (g_hertz > 1.0f) - std::cout << "" << std::setprecision(1) << std::setiosflags(std::ios::fixed) << timeTaken * g_hertz / length; + { + const double cpb = timeTaken * g_hertz / length; + if (cpb < 24.0f) + std::cout << "" << std::setprecision(2) << std::setiosflags(std::ios::fixed) << cpb; + else + std::cout << "" << std::setprecision(1) << std::setiosflags(std::ios::fixed) << cpb; + } g_logTotal += ::log(mbs); g_logCount++; } @@ -98,7 +104,10 @@ void OutputResultOperations(const char *name, const char *operation, bool pc, un // Coverity finding if (g_hertz > 1.0f) - std::cout << "" << std::setprecision(2) << std::setiosflags(std::ios::fixed) << timeTaken * g_hertz / iterations / 1000000; + { + const double t = timeTaken * g_hertz / iterations / 1000000; + std::cout << "" << std::setprecision(2) << std::setiosflags(std::ios::fixed) << t; + } g_logTotal += ::log(iterations/timeTaken); g_logCount++; -- cgit v1.2.1