changeset 5386:19e5dc8d0891

alphabetically sort debug values for Metric and Time
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 11 May 2012 14:39:58 +0200
parents 31ec401eb592
children b6aaf6de4053
files graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValue.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java
diffstat 2 files changed, 23 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValue.java	Thu May 10 14:24:25 2012 +0200
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValue.java	Fri May 11 14:39:58 2012 +0200
@@ -22,8 +22,24 @@
  */
 package com.oracle.graal.debug.internal;
 
+import java.util.*;
+
 public abstract class DebugValue {
 
+    public static final Comparator<DebugValue> ORDER_BY_NAME = new Comparator<DebugValue>() {
+        @Override
+        public int compare(DebugValue o1, DebugValue o2) {
+            // this keeps the "Runs" metric at the top of the list
+            if (o1.getName().equals("Runs")) {
+                return o2.getName().equals("Runs") ? 0 : -1;
+            }
+            if (o2.getName().equals("Runs")) {
+                return o1.getName().equals("Runs") ? 0 : 1;
+            }
+            return o1.getName().compareTo(o2.getName());
+        }
+    };
+
     private String name;
     private int index;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Thu May 10 14:24:25 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Fri May 11 14:39:58 2012 +0200
@@ -260,14 +260,17 @@
             List<DebugValueMap> topLevelMaps = DebugValueMap.getTopLevelMaps();
             List<DebugValue> debugValues = KeyRegistry.getDebugValues();
             if (debugValues.size() > 0) {
+                ArrayList<DebugValue> sortedValues = new ArrayList<>(debugValues);
+                Collections.sort(sortedValues, DebugValue.ORDER_BY_NAME);
+
                 if (GraalOptions.SummarizeDebugValues) {
-                    printSummary(topLevelMaps, debugValues);
+                    printSummary(topLevelMaps, sortedValues);
                 } else if (GraalOptions.PerThreadDebugValues) {
                     for (DebugValueMap map : topLevelMaps) {
                         TTY.println("Showing the results for thread: " + map.getName());
                         map.group();
                         map.normalize();
-                        printMap(map, debugValues, 0);
+                        printMap(map, sortedValues, 0);
                     }
                 } else {
                     DebugValueMap globalMap = new DebugValueMap("Global");
@@ -284,7 +287,7 @@
                         globalMap.group();
                     }
                     globalMap.normalize();
-                    printMap(globalMap, debugValues, 0);
+                    printMap(globalMap, sortedValues, 0);
                 }
             }
         }
@@ -331,6 +334,7 @@
 
         printIndent(level);
         TTY.println("%s", map.getName());
+
         for (DebugValue value : debugValues) {
             long l = map.getCurrentValue(value.getIndex());
             if (l != 0) {