[Openmp-commits] [openmp] r262658 - [STATS] fix output formatting when sample count is 0

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Thu Mar 3 13:24:14 PST 2016


Author: jlpeyton
Date: Thu Mar  3 15:24:13 2016
New Revision: 262658

URL: http://llvm.org/viewvc/llvm-project?rev=262658&view=rev
Log:
[STATS] fix output formatting when sample count is 0

Force 0.0 to be displayed for all statistics which have sample count equal to 0

Modified:
    openmp/trunk/runtime/src/kmp_stats.cpp

Modified: openmp/trunk/runtime/src/kmp_stats.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_stats.cpp?rev=262658&r1=262657&r2=262658&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_stats.cpp (original)
+++ openmp/trunk/runtime/src/kmp_stats.cpp Thu Mar  3 15:24:13 2016
@@ -129,14 +129,25 @@ void statistic::scale(double factor)
 std::string statistic::format(char unit, bool total) const
 {
     std::string result = formatSI(sampleCount,9,' ');
-
-    result = result + std::string(", ") + formatSI(minVal,  9, unit);
-    result = result + std::string(", ") + formatSI(meanVal, 9, unit);
-    result = result + std::string(", ") + formatSI(maxVal,  9, unit);
-    if (total)
-        result = result + std::string(", ") + formatSI(meanVal*sampleCount, 9, unit);
-    result = result + std::string(", ") + formatSI(getSD(), 9, unit);
-
+    
+    if (sampleCount == 0)
+    {
+        result = result + std::string(", ") + formatSI(0.0, 9, unit);
+        result = result + std::string(", ") + formatSI(0.0, 9, unit);
+        result = result + std::string(", ") + formatSI(0.0, 9, unit);
+        if (total)
+            result = result + std::string(", ") + formatSI(0.0, 9, unit);
+        result = result + std::string(", ") + formatSI(0.0, 9, unit);
+    }
+    else
+    {
+        result = result + std::string(", ") + formatSI(minVal,  9, unit);
+        result = result + std::string(", ") + formatSI(meanVal, 9, unit);
+        result = result + std::string(", ") + formatSI(maxVal,  9, unit);
+        if (total)
+            result = result + std::string(", ") + formatSI(meanVal*sampleCount, 9, unit);
+        result = result + std::string(", ") + formatSI(getSD(), 9, unit);
+    }
     return result;
 }
 




More information about the Openmp-commits mailing list