8006944: javac, combo tests should print out the number of threads used
authorvromero
Sun, 27 Jan 2013 19:38:44 +0000
changeset 15551 64c22739fdb8
parent 15386 92bc08d96f0c
child 15552 99e4c7eb352c
8006944: javac, combo tests should print out the number of threads used Reviewed-by: mcimadamore
langtools/test/tools/javac/lib/JavacTestingAbstractThreadedTest.java
--- a/langtools/test/tools/javac/lib/JavacTestingAbstractThreadedTest.java	Wed Jan 23 20:11:07 2013 -0800
+++ b/langtools/test/tools/javac/lib/JavacTestingAbstractThreadedTest.java	Sun Jan 27 19:38:44 2013 +0000
@@ -41,14 +41,20 @@
  *
  * If the property is not set the class will use a heuristic to determine the
  * maximum number of threads that can be fired to execute a given test.
+ *
+ * This code will have to be revisited if jprt starts using concurrency for
+ * for running jtreg tests.
  */
 public abstract class JavacTestingAbstractThreadedTest {
 
+    protected static AtomicInteger numberOfThreads = new AtomicInteger();
+
     protected static int getThreadPoolSize() {
         Integer testConc = Integer.getInteger("test.concurrency");
         if (testConc != null) return testConc;
         int cores = Runtime.getRuntime().availableProcessors();
-        return Math.max(2, Math.min(8, cores / 2));
+        numberOfThreads.set(Math.max(2, Math.min(8, cores / 2)));
+        return numberOfThreads.get();
     }
 
     protected static void checkAfterExec() throws InterruptedException {
@@ -82,11 +88,18 @@
         } else if (printCheckCount) {
             outWriter.println("Total check executed: " + checkCount.get());
         }
+        /*
+         * This output is for supporting debugging. It does not mean that a given
+         * test had executed that number of threads concurrently. The value printed
+         * here is the maximum possible amount.
+         */
         closePrinters();
         if (printAll) {
             System.out.println(errSWriter.toString());
             System.out.println(outSWriter.toString());
         }
+        System.out.println("Total number of threads in thread pool: " +
+                numberOfThreads.get());
     }
 
     protected static void closePrinters() {