< prev index next >

src/share/vm/gc/g1/workerDataArray.cpp

Print this page

        

@@ -22,36 +22,68 @@
  *
  */
 
 #include "precompiled.hpp"
 #include "gc/g1/workerDataArray.inline.hpp"
+#include "utilities/ostream.hpp"
+
+template <>
+void WorkerDataArray<double>::WDAPrinter::summary(outputStream* out, const char* title, double min, double avg, double max, double diff, double sum, bool print_sum) {
+  out->print("%-25s Min: %4.1lf, Avg: %4.1lf, Max: %4.1lf, Diff: %4.1lf", title, min * MILLIUNITS, avg * MILLIUNITS, max * MILLIUNITS, diff* MILLIUNITS);
+  if (print_sum) {
+    out->print_cr(", Sum: %4.1lf", sum * MILLIUNITS);
+  } else {
+    out->cr();
+  }
+}
+
+template <>
+void WorkerDataArray<size_t>::WDAPrinter::summary(outputStream* out, const char* title, size_t min, double avg, size_t max, size_t diff, size_t sum, bool print_sum) {
+  out->print("%-25s Min: " SIZE_FORMAT ", Avg: %4.1lf, Max: " SIZE_FORMAT ", Diff: " SIZE_FORMAT, title, min, avg, max, diff);
+  if (print_sum) {
+    out->print_cr(", Sum: " SIZE_FORMAT, sum);
+  } else {
+    out->cr();
+  }
+}
+
+template <>
+void WorkerDataArray<double>::WDAPrinter::details(const WorkerDataArray<double>* phase, outputStream* out, uint active_threads) {
+  out->print("%-25s", "");
+  for (uint i = 0; i < active_threads; ++i) {
+    out->print(" %4.1lf", phase->get(i) * 1000.0);
+  }
+  out->cr();
+}
+
+template <>
+void WorkerDataArray<size_t>::WDAPrinter::details(const WorkerDataArray<size_t>* phase, outputStream* out, uint active_threads) {
+  out->print("%-25s", "");
+  for (uint i = 0; i < active_threads; ++i) {
+    out->print("  " SIZE_FORMAT, phase->get(i));
+  }
+  out->cr();
+}
 
 #ifndef PRODUCT
 void WorkerDataArray_test() {
   const uint length = 3;
   const char* title = "Test array";
-  const bool print_sum = false;
-  const uint indent_level = 2;
 
-  WorkerDataArray<size_t> array(length, title, print_sum, indent_level);
+  WorkerDataArray<size_t> array(length, title);
   assert(strncmp(array.title(), title, strlen(title)) == 0 , "Expected titles to match");
-  assert(array.should_print_sum() == print_sum, "Expected should_print_sum to match print_sum");
-  assert(array.indentation() == indent_level, "Expected indentation to match");
 
   const size_t expected[length] = {5, 3, 7};
   for (uint i = 0; i < length; i++) {
     array.set(i, expected[i]);
   }
   for (uint i = 0; i < length; i++) {
     assert(array.get(i) == expected[i], "Expected elements to match");
   }
 
   assert(array.sum(length) == (5 + 3 + 7), "Expected sums to match");
-  assert(array.minimum(length) == 3, "Expected mininum to match");
-  assert(array.maximum(length) == 7, "Expected maximum to match");
-  assert(array.diff(length) == (7 - 3), "Expected diffs to match");
-  assert(array.average(length) == 5, "Expected averages to match");
+  assert(array.average(length) == 5.0, "Expected averages to match");
 
   for (uint i = 0; i < length; i++) {
     array.add(i, 1);
   }
   for (uint i = 0; i < length; i++) {
< prev index next >