changeset 4563:b27666ff9bd6

added compilation time statistics to product mode
author Christian Haeubl <christian.haeubl@oracle.com>
date Fri, 10 Feb 2012 11:14:51 -0800
parents ef00461e29af
children 8fc6920e064b
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java
diffstat 2 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Fri Feb 10 10:16:19 2012 -0800
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Fri Feb 10 11:14:51 2012 -0800
@@ -95,6 +95,9 @@
     public static boolean PrintLIR                           = ____;
     public static boolean PrintCFGToFile                     = ____;
 
+    // statistics independent from debug mode
+    public static boolean PrintCompilationStatistics         = ____;
+
     // Debug settings:
     public static boolean Debug                              = true;
     public static boolean SummarizeDebugValues               = ____;
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java	Fri Feb 10 10:16:19 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java	Fri Feb 10 11:14:51 2012 -0800
@@ -50,6 +50,7 @@
 
     private final Compiler compiler;
     private int compiledMethodCount;
+    private long totalCompilationTime;
     private IntrinsifyArrayCopyPhase intrinsifyArrayCopy;
 
     public final HotSpotTypePrimitive typeBoolean;
@@ -217,6 +218,16 @@
                 }
             }
         }
+
+        if (GraalOptions.PrintCompilationStatistics) {
+            printCompilationStatistics();
+        }
+    }
+
+    private void printCompilationStatistics() {
+        TTY.println("Accumulated compilation statistics");
+        TTY.println("  Compiled methods         : %d", compiledMethodCount);
+        TTY.println("  Total compilation time   : %6.3f s", totalCompilationTime / Math.pow(10, 9));
     }
 
     private static void printSummary(List<DebugValueMap> topLevelMaps, List<DebugValue> debugValues) {
@@ -290,16 +301,16 @@
                         final PhasePlan plan = getDefaultPhasePlan();
                         GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(compiler.getRuntime());
                         plan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase);
-                        long startTime = 0;
+                        long startTime = System.nanoTime();
                         int index = compiledMethodCount++;
                         final boolean printCompilation = GraalOptions.PrintCompilation && !TTY.isSuppressed();
                         if (printCompilation) {
                             TTY.println(String.format("Graal %4d %-70s %-45s %-50s ...", index, method.holder().name(), method.name(), method.signature().asString()));
-                            startTime = System.nanoTime();
                         }
 
                         CiTargetMethod result = null;
                         TTY.Filter filter = new TTY.Filter(GraalOptions.PrintFilter, method);
+                        long nanoTime;
                         try {
                             result = Debug.scope("Compiling", method, new Callable<CiTargetMethod>() {
                                 @Override
@@ -309,9 +320,10 @@
                             });
                         } finally {
                             filter.remove();
+                            nanoTime = System.nanoTime() - startTime;
+                            totalCompilationTime += nanoTime;
                             if (printCompilation) {
-                                long time = (System.nanoTime() - startTime) / 100000;
-                                TTY.println(String.format("Graal %4d %-70s %-45s %-50s | %3d.%dms %4dnodes %5dB", index, "", "", "", time / 10, time % 10, 0, (result != null ? result.targetCodeSize()
+                                TTY.println(String.format("Graal %4d %-70s %-45s %-50s | %3d.%dms %4dnodes %5dB", index, "", "", "", nanoTime / 1000000, nanoTime % 1000000, 0, (result != null ? result.targetCodeSize()
                                                 : -1)));
                             }
                         }