Author: [email protected]
Date: Mon Jun 8 12:49:29 2009
New Revision: 5521
Modified:
trunk/tools/soyc-vis/src/com/google/gwt/soyc/GlobalInformation.java
trunk/tools/soyc-vis/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java
trunk/tools/soyc-vis/src/com/google/gwt/soyc/Settings.java
trunk/tools/soyc-vis/src/com/google/gwt/soyc/SizeBreakdown.java
trunk/tools/soyc-vis/src/com/google/gwt/soyc/SoycDashboard.java
Log:
SOYC adds a drill-down size breakdown for the exclusive and leftover
fragments, just like the one it currently gives for the total program
and the initial download.
Review by: kprobst
Modified:
trunk/tools/soyc-vis/src/com/google/gwt/soyc/GlobalInformation.java
==============================================================================
--- trunk/tools/soyc-vis/src/com/google/gwt/soyc/GlobalInformation.java
(original)
+++ trunk/tools/soyc-vis/src/com/google/gwt/soyc/GlobalInformation.java Mon
Jun 8 12:49:29 2009
@@ -16,8 +16,10 @@
package com.google.gwt.soyc;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;
@@ -26,6 +28,7 @@
* Information global to the entire SOYC report generator.
*/
public class GlobalInformation {
+ private static final SizeBreakdown[] EMPTY_SIZE_BREAKDOWN = new
SizeBreakdown[0];
public static String backupLocation = "(Source location not known)";
@@ -52,11 +55,24 @@
public static SizeBreakdown initialCodeBreakdown = new SizeBreakdown(
"Initially downloaded code", "initial");
+ public static SizeBreakdown leftoversBreakdown = new SizeBreakdown(
+ "Leftovers code, neither initial nor exclusive to any split point",
+ "leftovers");
public static SizeBreakdown totalCodeBreakdown = new SizeBreakdown(
"Total program", "total");
+ private static Map<Integer, SizeBreakdown> exclusiveCodeBreakdowns = new
HashMap<Integer, SizeBreakdown>();
public static SizeBreakdown[] allSizeBreakdowns() {
- return new SizeBreakdown[] {totalCodeBreakdown, initialCodeBreakdown};
+ List<SizeBreakdown> breakdowns = new ArrayList<SizeBreakdown>();
+ breakdowns.add(totalCodeBreakdown);
+ breakdowns.add(initialCodeBreakdown);
+ if (numSplitPoints > 0) {
+ breakdowns.add(leftoversBreakdown);
+ for (int sp = 1; sp <= numSplitPoints; sp++) {
+ breakdowns.add(exclusiveCodeBreakdown(sp));
+ }
+ }
+ return breakdowns.toArray(EMPTY_SIZE_BREAKDOWN);
}
public static void computePackageSizes() {
@@ -67,8 +83,18 @@
public static void computePartialPackageSizes() {
for (SizeBreakdown breakdown : allSizeBreakdowns()) {
- computePartialPackageSizes(breakdown.packageToPartialSize,
breakdown.classToPartialSize);
+ computePartialPackageSizes(breakdown.packageToPartialSize,
+ breakdown.classToPartialSize);
+ }
+ }
+
+ public static SizeBreakdown exclusiveCodeBreakdown(int sp) {
+ assert sp >= 1 && sp <= numSplitPoints;
+ if (!exclusiveCodeBreakdowns.containsKey(sp)) {
+ exclusiveCodeBreakdowns.put(sp, new SizeBreakdown("split point " + sp
+ + ": " + splitPointToLocation.get(sp), "sp" + sp));
}
+ return exclusiveCodeBreakdowns.get(sp);
}
private static void computePackageSizes(Map<String, Integer>
packageToSize,
Modified:
trunk/tools/soyc-vis/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java
==============================================================================
---
trunk/tools/soyc-vis/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java
(original)
+++
trunk/tools/soyc-vis/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java
Mon Jun 8 12:49:29 2009
@@ -32,7 +32,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
-import java.util.TreeSet;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarInputStream;
@@ -615,30 +614,37 @@
int numSplitPoints = GlobalInformation.splitPointToLocation.size();
- int outerHeight = 25 * (numSplitPoints + 2);
+ int numRows = 2;
+ if (numSplitPoints > 0) {
+ // add one for the leftovers fragment
+ numRows += numSplitPoints + 1;
+ }
+ int outerHeight = 25 * numRows;
outFile.println("<div style=\"width:100%; margin:20px 0 20px 0;
background-color:white;position:relative;height:"
+ outerHeight + "\">");
float maxSize = GlobalInformation.totalCodeBreakdown.sizeAllCode;
int yOffset = 0;
- for (int i = FRAGMENT_NUMBER_TOTAL_PROGRAM; i <= numSplitPoints; i++) {
- String drillDownFileName, splitPointDescription;
+ for (int i = FRAGMENT_NUMBER_TOTAL_PROGRAM; i <= numSplitPoints + 1;
i++) {
+ if (i == 1 && numSplitPoints == 0) {
+ // don't show the leftovers fragment if the split points aren't
known
+ continue;
+ }
+
+ SizeBreakdown breakdown;
if (i == FRAGMENT_NUMBER_TOTAL_PROGRAM) {
- drillDownFileName =
shellFileName(GlobalInformation.totalCodeBreakdown);
- splitPointDescription = "Total program";
+ breakdown = GlobalInformation.totalCodeBreakdown;
+ } else if (i == numSplitPoints + 1) {
+ breakdown = GlobalInformation.leftoversBreakdown;
+ } else if (i == FRAGMENT_NUMBER_INITIAL_DOWNLOAD) {
+ breakdown = GlobalInformation.initialCodeBreakdown;
} else {
- String splitPointName = i == FRAGMENT_NUMBER_INITIAL_DOWNLOAD
- ? "initialDownload" :
GlobalInformation.splitPointToLocation.get(i);
- if (i == FRAGMENT_NUMBER_INITIAL_DOWNLOAD) {
- drillDownFileName =
shellFileName(GlobalInformation.initialCodeBreakdown);
- } else {
- drillDownFileName = "splitPoint-" + filename(splitPointName)
- + "-Classes.html";
- }
- splitPointDescription = i == FRAGMENT_NUMBER_INITIAL_DOWNLOAD
- ? "Initial download" : ("Code exclusive to " + splitPointName);
+ breakdown = GlobalInformation.exclusiveCodeBreakdown(i);
}
+ String drillDownFileName = shellFileName(breakdown);
+ String splitPointDescription = breakdown.getDescription();
+
float size;
if (i >= 0) {
size = GlobalInformation.fragmentToPartialSize.get(i);
@@ -1253,139 +1259,6 @@
outFile.println("</body>");
outFile.println("</html>");
outFile.close();
- }
- }
-
- /**
- * Makes html file for fragment classes. TODO(kprobst): update this once
we
- * have SOYC updated to supply enough information
- *
- * TODO(spoon) instead of this listing, make a size breakdown for each
- * exclusive fragment
- */
- public void makeSplitPointClassesHtmls() throws IOException {
-
- // for the initial fragment and the fragments in the load order, we can
- // print this immediately
- // For those fragments *not* in the initial load order, we just
collect and
- // then print at the end
- TreeSet<String> sortedClassesAndMethodsAllOtherFragments = new
TreeSet<String>();
-
- for (Integer fragmentName :
GlobalInformation.fragmentToStories.keySet()) {
- if (fragmentName == FRAGMENT_NUMBER_INITIAL_DOWNLOAD) {
- /*
- * For the initial download, a size breakdown is availale to
replace the
- * split point class listing
- */
- continue;
- }
-
- if
(!GlobalInformation.splitPointToLocation.containsKey(fragmentName)) {
- // get the stories from ALL the fragments
- for (String storyName :
GlobalInformation.fragmentToStories.get(fragmentName)) {
- if
((!GlobalInformation.totalCodeBreakdown.nameToLitColl.get("string").storyToLocations.containsKey(storyName))
- &&
(GlobalInformation.storiesToCorrClassesAndMethods.containsKey(storyName))) {
- for (String className :
GlobalInformation.storiesToCorrClassesAndMethods.get(storyName)) {
- sortedClassesAndMethodsAllOtherFragments.add(className);
- }
- }
- }
- } else {
- String curSplitPointLocation;
-
- if (fragmentName == FRAGMENT_NUMBER_INITIAL_DOWNLOAD) {
- curSplitPointLocation = "initialDownload";
- } else {
- curSplitPointLocation =
GlobalInformation.splitPointToLocation.get(fragmentName);
- }
-
- String outFileName = "splitPoint-" +
filename(curSplitPointLocation)
- + "-Classes.html";
-
- final PrintWriter outFile = new
PrintWriter(getOutFile(outFileName));
-
- outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML
4.01//EN\"");
- outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\">");
- outFile.println("<html>");
- outFile.println("<head>");
- outFile.println("<meta http-equiv=\"content-type\"
content=\"text/html;charset=ISO-8859-1\">");
- outFile.println("<title>Classes and methods in exclusives fragment
for runAsync split point \""
- + curSplitPointLocation + "\" </title>");
- outFile.println("</head>");
-
- outFile.println("<style type=\"text/css\">");
- outFile.println("body {background-color: #728FCE}");
- outFile.println("h2 {background-color: transparent}");
- outFile.println("p {background-color: fuchsia}");
- outFile.println(".tablediv {");
- outFile.println("display: table;");
- outFile.println("width:100%;");
- outFile.println("background-color:#eee;");
- outFile.println("border:1px solid #666666;");
- outFile.println("border-spacing:5px;");
- outFile.println("border-collapse:separate;");
- outFile.println("}");
- outFile.println(".celldiv {");
- outFile.println("float:left;");
- outFile.println("display: table-cell;");
- outFile.println("width:49.5%;");
- outFile.println("font-size: 14px;");
- outFile.println("background-color:white;");
- outFile.println("}");
- outFile.println(".rowdiv {");
- outFile.println("display: table-row;");
- outFile.println("width:100%;");
- outFile.println("}");
- outFile.println("</style>");
-
- outFile.println("<body>");
- outFile.println("<center>");
- outFile.println("<h2>Classes and methods in exclusives fragment
for runAsync split point \""
- + curSplitPointLocation + "\"</h2>");
- outFile.println("</center>");
- outFile.println("<hr>");
-
- outFile.println("<div style=\"width:90%; height:80%;
overflow-y:auto; overflow-x:auto; top: 30px; left:60px; position:relative;
background-color:white\"");
- outFile.println("<div class=\"tablediv\">");
-
- TreeSet<String> sortedClassesAndMethods = new TreeSet<String>();
- for (String storyName :
GlobalInformation.fragmentToStories.get(fragmentName)) {
- if
((!GlobalInformation.totalCodeBreakdown.nameToLitColl.get("string").storyToLocations.containsKey(storyName))
- &&
(GlobalInformation.storiesToCorrClassesAndMethods.containsKey(storyName))) {
- for (String className :
GlobalInformation.storiesToCorrClassesAndMethods.get(storyName)) {
- sortedClassesAndMethods.add(className);
- }
- }
- }
- for (String classOrMethod : sortedClassesAndMethods) {
-
- // if it's a method
- if ((GlobalInformation.displayDependencies == true)
- && (classOrMethod.contains("(")) &&
(classOrMethod.contains(")"))) {
- // get the package
- String packageName = classOrMethod;
- packageName = packageName.replaceAll("\\.\\p{Upper}.*", "");
-
- String noParamMethod = classOrMethod;
- noParamMethod = noParamMethod.replaceAll("\\(.*", "");
-
- outFile.println("<div class=\"rowdiv\"><a
href=\"methodDependencies-"
- + filename(packageName)
- + ".html#"
- + noParamMethod
- + "\">"
- + classOrMethod + "</a></div>");
- } else {
- outFile.println("<div class=\"rowdiv\">" + classOrMethod
- + "</div>");
- }
- }
-
- outFile.println("</div>");
- outFile.println("</body>");
- outFile.println("</html>");
- outFile.close();
- }
}
}
}
Modified: trunk/tools/soyc-vis/src/com/google/gwt/soyc/Settings.java
==============================================================================
--- trunk/tools/soyc-vis/src/com/google/gwt/soyc/Settings.java (original)
+++ trunk/tools/soyc-vis/src/com/google/gwt/soyc/Settings.java Mon Jun 8
12:49:29 2009
@@ -117,8 +117,7 @@
}
if (settings.resources.get() == null) {
- throw new ArgumentListException("Missing option -resources: "
- + Settings.settingsHelp());
+ throw new ArgumentListException("The -resources option is required");
}
if (remainingArguments.isEmpty()) {
Modified: trunk/tools/soyc-vis/src/com/google/gwt/soyc/SizeBreakdown.java
==============================================================================
--- trunk/tools/soyc-vis/src/com/google/gwt/soyc/SizeBreakdown.java
(original)
+++ trunk/tools/soyc-vis/src/com/google/gwt/soyc/SizeBreakdown.java Mon
Jun 8 12:49:29 2009
@@ -87,4 +87,9 @@
public String getId() {
return id;
}
+
+ @Override
+ public String toString() {
+ return getId();
+ }
}
Modified: trunk/tools/soyc-vis/src/com/google/gwt/soyc/SoycDashboard.java
==============================================================================
--- trunk/tools/soyc-vis/src/com/google/gwt/soyc/SoycDashboard.java
(original)
+++ trunk/tools/soyc-vis/src/com/google/gwt/soyc/SoycDashboard.java Mon
Jun 8 12:49:29 2009
@@ -161,20 +161,6 @@
}
/*
- * unescape the JS snippets - in the XML file they are XML encoded for
correct
- * display, but this will mess up the byte counts
- */
- public static String unEscapeXml(String escaped) {
- String unescaped = escaped.replaceAll("&", "\\&");
- unescaped = unescaped.replaceAll("<", "\\<");
- unescaped = unescaped.replaceAll(">", "\\>");
- unescaped = unescaped.replaceAll(""", "\\\"");
- // escaped = escaped.replaceAll("\\n", "");
- unescaped = unescaped.replaceAll("'", "\\'");
- return unescaped;
- }
-
- /*
* cleans up the RPC code categories
*/
private static void foldInRPCHeuristic(
@@ -218,7 +204,6 @@
makeTopLevelHtmlForPerm.makeCodeTypeClassesHtmls(breakdown);
makeTopLevelHtmlForPerm.makeLiteralsClassesTableHtmls(breakdown);
makeTopLevelHtmlForPerm.makeStringLiteralsClassesTableHtmls(breakdown);
- makeTopLevelHtmlForPerm.makeSplitPointClassesHtmls();
makeTopLevelHtmlForPerm.makeBreakdownShell(breakdown);
makeTopLevelHtmlForPerm.makeTopLevelShell();
}
@@ -394,6 +379,12 @@
breakdowns.add(GlobalInformation.totalCodeBreakdown);
if (curFragment == 0) {
breakdowns.add(GlobalInformation.initialCodeBreakdown);
+ }
+ if (curFragment == (GlobalInformation.numSplitPoints+1)) {
+ breakdowns.add(GlobalInformation.leftoversBreakdown);
+ }
+ if (curFragment >= 1 && curFragment <=
GlobalInformation.numSplitPoints) {
+
breakdowns.add(GlobalInformation.exclusiveCodeBreakdown(curFragment));
}
return breakdowns;
}
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---