Revision: 5993 Author: [email protected] Date: Fri Aug 21 10:48:30 2009 Log: This patch moves SOYC's source code underneath dev/core/src. It leaves gwt-soyc-vis.jar existing and containing the SOYC static resources (css and gifs). It has gwt-dev-platform.jar also contain the SOYC static resources.
After this patch, any existing build rules and scripts should be able to replace references to gwt-soyc-vis.jar by references to gwt-dev-platform.jar. Review by: fabbott http://code.google.com/p/google-web-toolkit/source/detail?r=5993 Added: /trunk/dev/core/src/com/google/gwt/soyc Deleted: /trunk/tools/soyc-vis/src/com/google/gwt/soyc Modified: /trunk/dev/common.ant.xml /trunk/dev/core/src/com/google/gwt/soyc/GlobalInformation.java /trunk/dev/core/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java /trunk/dev/core/src/com/google/gwt/soyc/Settings.java /trunk/dev/core/src/com/google/gwt/soyc/SizeBreakdown.java /trunk/tools/soyc-vis/build.xml ======================================= --- /trunk/dev/common.ant.xml Wed Jun 10 14:39:00 2009 +++ /trunk/dev/common.ant.xml Fri Aug 21 10:48:30 2009 @@ -4,6 +4,7 @@ <property.ensure name="gwt.core.root" location="../core" /> <property.ensure name="gwt.core.build" location="${project.build}/../core" /> + <property.ensure name="gwt.tools.soyc" location="${gwt.root}/tools/soyc-vis" /> <target name="compile" description="Compile all java files"> <mkdir dir="${javac.out}" /> @@ -30,6 +31,9 @@ <fileset dir="${gwt.core.build}/bin" /> <fileset file="${gwt.tools.lib}/eclipse/${gwt.dev.swt.jar}" /> <fileset file="${gwt.core.build}/alldeps.jar" /> + <fileset dir="${gwt.tools.soyc}/images"/> + <fileset file="${gwt.tools.soyc}/classLevel.css"/> + <fileset file="${gwt.tools.soyc}/roundedCorners.css"/> </sourcefiles> <targetfiles> <fileset file="${project.lib}"/> @@ -46,6 +50,11 @@ <fileset dir="${gwt.core.build}/bin" /> <zipfileset src="${gwt.tools.lib}/eclipse/${gwt.dev.swt.jar}" /> <zipfileset src="${gwt.core.build}/alldeps.jar" /> + + <zipfileset dir="${gwt.tools.soyc}/images" prefix="com/google/gwt/soyc/resources/images"/> + <zipfileset file="${gwt.tools.soyc}/classLevel.css" prefix="com/google/gwt/soyc/resources/"/> + <zipfileset file="${gwt.tools.soyc}/roundedCorners.css" prefix="com/google/gwt/soyc/resources/"/> + <manifest> <attribute name="Main-Class" value="com.google.gwt.dev.GWTMain" /> </manifest> ======================================= --- /trunk/tools/soyc-vis/src/com/google/gwt/soyc/GlobalInformation.java Mon Aug 17 07:08:53 2009 +++ /trunk/dev/core/src/com/google/gwt/soyc/GlobalInformation.java Fri Aug 21 10:48:30 2009 @@ -28,9 +28,9 @@ * Information global to the entire SOYC report generator. */ public class GlobalInformation { + private static final SizeBreakdown[] EMPTY_SIZE_BREAKDOWN = new SizeBreakdown[0]; private HashMap<String, String> classToPackage = new HashMap<String, String>(); private HashMap<String, HashSet<String>> classToWhatItDependsOn = new HashMap<String, HashSet<String>>(); - private final SizeBreakdown[] EMPTY_SIZE_BREAKDOWN = new SizeBreakdown[0]; private Map<Integer, SizeBreakdown> exclusiveCodeBreakdowns = new HashMap<Integer, SizeBreakdown>(); private SizeBreakdown initialCodeBreakdown = new SizeBreakdown( "Initially downloaded code", "initial"); @@ -38,11 +38,11 @@ "Leftovers code, code not in any other category", "leftovers"); private int numSplitPoints = 0; private Map<String, TreeSet<String>> packageToClasses = new TreeMap<String, TreeSet<String>>(); - private HashMap<Integer, String> splitPointToLocation = new HashMap<Integer, String>(); private ArrayList<Integer> splitPointInitialLoadSequence = new ArrayList<Integer>(); + private HashMap<Integer, String> splitPointToLocation = new HashMap<Integer, String>(); private SizeBreakdown totalCodeBreakdown = new SizeBreakdown("Total program", "total"); - + public SizeBreakdown[] allSizeBreakdowns() { List<SizeBreakdown> breakdowns = new ArrayList<SizeBreakdown>(); breakdowns.add(totalCodeBreakdown); @@ -55,7 +55,7 @@ } return breakdowns.toArray(EMPTY_SIZE_BREAKDOWN); } - + /** * Computes all package sizes. */ @@ -65,28 +65,6 @@ } } - /** - * Computes package sizes from class sizes. TODO(spoon) move this to the - * SizeBreakdown class. - * - * @param packageToSize mapping from packages to their sizes - * @param classToSize mapping from classes to their sizes - */ - private void computePackageSizes(Map<String, Integer> packageToSize, - Map<String, Integer> classToSize) { - packageToSize.clear(); - for (String packageName : packageToClasses.keySet()) { - packageToSize.put(packageName, 0); - for (String className : packageToClasses.get(packageName)) { - if (classToSize.containsKey(className)) { - int curSize = classToSize.get(className); - int newSize = curSize + packageToSize.get(packageName); - packageToSize.put(packageName, newSize); - } - } - } - } - /** * Gets the mapping from each class to its package. * @@ -113,7 +91,7 @@ public final Map<Integer, SizeBreakdown> getExclusiveCodeBreakdowns() { return exclusiveCodeBreakdowns; } - + /** * Gets the initial code breakdown. * @@ -131,7 +109,7 @@ public final SizeBreakdown getLeftoversBreakdown() { return leftoversBreakdown; } - + /** * Gets the number of split points. * @@ -149,7 +127,7 @@ public final Map<String, TreeSet<String>> getPackageToClasses() { return packageToClasses; } - + /** * Gets the initial load sequence. * @@ -167,7 +145,7 @@ public final HashMap<Integer, String> getSplitPointToLocation() { return splitPointToLocation; } - + /** * Gets the total code breakdown. * @@ -176,7 +154,7 @@ public final SizeBreakdown getTotalCodeBreakdown() { return totalCodeBreakdown; } - + /** * Increments the split point count. */ @@ -198,5 +176,27 @@ } return exclusiveCodeBreakdowns.get(sp); } + + /** + * Computes package sizes from class sizes. TODO(spoon) move this to the + * SizeBreakdown class. + * + * @param packageToSize mapping from packages to their sizes + * @param classToSize mapping from classes to their sizes + */ + private void computePackageSizes(Map<String, Integer> packageToSize, + Map<String, Integer> classToSize) { + packageToSize.clear(); + for (String packageName : packageToClasses.keySet()) { + packageToSize.put(packageName, 0); + for (String className : packageToClasses.get(packageName)) { + if (classToSize.containsKey(className)) { + int curSize = classToSize.get(className); + int newSize = curSize + packageToSize.get(packageName); + packageToSize.put(packageName, newSize); + } + } + } + } } ======================================= --- /trunk/tools/soyc-vis/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java Mon Aug 17 13:34:09 2009 +++ /trunk/dev/core/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java Fri Aug 21 10:48:30 2009 @@ -43,12 +43,19 @@ * A utility to make the top level HTTML file for one permutation. */ public class MakeTopLevelHtmlForPerm { + /** + * A dependency linker for exclusive fragments. It links to nothing. + */ public class DependencyLinkerForExclusiveFragment implements DependencyLinker { public String dependencyLinkForClass(String className, String permutationId) { return null; } } + /** + * A dependency linker for the initial code download. It links to the + * dependencies for the initial download. + */ public class DependencyLinkerForInitialCode implements DependencyLinker { public String dependencyLinkForClass(String className, String permutationId) { String packageName = globalInformation.getClassToPackage().get(className); @@ -58,12 +65,21 @@ } } + /** + * A dependency linker for the leftovers fragment. It links to leftovers + * status pages. + */ public class DependencyLinkerForLeftoversFragment implements DependencyLinker { public String dependencyLinkForClass(String className, String permutationId) { return leftoversStatusFileName(className, permutationId); } } + /** + * A dependency linker for the total program breakdown. It links to a split + * status page. + * + */ public class DependencyLinkerForTotalBreakdown implements DependencyLinker { public String dependencyLinkForClass(String className, String permutationId) { return splitStatusFileName(className, permutationId); @@ -73,33 +89,6 @@ interface DependencyLinker { String dependencyLinkForClass(String className, String permutationId); } - - /** - * Default constructor. Will be used for all permutations. - */ - MakeTopLevelHtmlForPerm() { - this.globalInformation = new GlobalInformation(); - this.settings = new Settings(); - } - - /** - * Constructor for a specific permutation. - * - * @param globalInformation All the information about this permutation - */ - MakeTopLevelHtmlForPerm(final GlobalInformation globalInformation) { - this.globalInformation = globalInformation; - } - - /** - * Global information for this permutation. - */ - private GlobalInformation globalInformation = new GlobalInformation(); - - /** - * Settings for this permutation. - */ - private Settings settings = new Settings(); /** * By a convention shared with the compiler, the initial download is fragment @@ -125,6 +114,83 @@ '.', '/') + "/resources/"; + public static String escapeXml(String unescaped) { + String escaped = unescaped.replaceAll("\\&", "&"); + escaped = escaped.replaceAll("\\<", "<"); + escaped = escaped.replaceAll("\\>", ">"); + escaped = escaped.replaceAll("\\\"", """); + escaped = escaped.replaceAll("\\'", "'"); + return escaped; + } + + private static void addCenteredHeader(final PrintWriter outFile, String header) { + outFile.println("<hr>"); + outFile.println("<b>" + header + "</b>"); + outFile.println("<hr>"); + } + + /** + * Adds a header line indicating which breakdown is being analyzed. + */ + private static void addHeaderWithBreakdownContext(SizeBreakdown breakdown, + final PrintWriter outFile) { + addCenteredHeader(outFile, headerLineForBreakdown(breakdown)); + } + + private static String classesInPackageFileName(SizeBreakdown breakdown, + String packageName, String permutationId) { + return breakdown.getId() + "_" + packageName + "-" + permutationId + + "_Classes.html"; + } + + /** + * Convert a potentially long string into a short file name. The current + * implementation simply hashes the long name. + */ + private static String filename(String longFileName) { + try { + return Util.computeStrongName(longFileName.getBytes(Util.DEFAULT_ENCODING)); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + } + + private static String headerLineForBreakdown(SizeBreakdown breakdown) { + return "(Analyzing code subset: " + breakdown.getDescription() + ")"; + } + + private static String shellFileName(SizeBreakdown breakdown, + String permutationId) { + return breakdown.getId() + "-" + permutationId + "-overallBreakdown.html"; + } + + /** + * Global information for this permutation. + */ + private GlobalInformation globalInformation = new GlobalInformation(); + + /** + * Settings for this permutation. + */ + private Settings settings = new Settings(); + + /** + * Default constructor. Will be used for all permutations. + */ + MakeTopLevelHtmlForPerm() { + this.globalInformation = new GlobalInformation(); + this.settings = new Settings(); + } + + /** + * Constructor for a specific permutation. + * + * @param globalInformation All the information about this permutation + */ + MakeTopLevelHtmlForPerm(final GlobalInformation globalInformation) { + this.globalInformation = globalInformation; + } + public void copyFileOrDirectory(File srcPath, File dstPath, String classPath, String inputFileName, boolean isDirectory) throws IOException { if (srcPath.isDirectory()) { @@ -193,216 +259,8 @@ } } - public static String escapeXml(String unescaped) { - String escaped = unescaped.replaceAll("\\&", "&"); - escaped = escaped.replaceAll("\\<", "<"); - escaped = escaped.replaceAll("\\>", ">"); - escaped = escaped.replaceAll("\\\"", """); - escaped = escaped.replaceAll("\\'", "'"); - return escaped; - } - - private static void addCenteredHeader(final PrintWriter outFile, String header) { - outFile.println("<hr>"); - outFile.println("<b>" + header + "</b>"); - outFile.println("<hr>"); - } - - /** - * Adds a header line indicating which breakdown is being analyzed. - */ - private static void addHeaderWithBreakdownContext(SizeBreakdown breakdown, - final PrintWriter outFile) { - addCenteredHeader(outFile, headerLineForBreakdown(breakdown)); - } - - private static String classesInPackageFileName(SizeBreakdown breakdown, - String packageName, String permutationId) { - return breakdown.getId() + "_" + packageName + "-" + permutationId - + "_Classes.html"; - } - - /** - * Convert a potentially long string into a short file name. The current - * implementation simply hashes the long name. - */ - private static String filename(String longFileName) { - try { - return Util.computeStrongName(longFileName.getBytes(Util.DEFAULT_ENCODING)); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - - /** - * Return a {...@link File} object for a file to be emitted into the output - * directory. - */ - private File getOutFile(String localFileName) { - File outDir = new File(settings.out.get()); - return new File(outDir, localFileName); - } - - private static String headerLineForBreakdown(SizeBreakdown breakdown) { - return "(Analyzing code subset: " + breakdown.getDescription() + ")"; - } - - /** - * Describe the code covered by the dependency graph with the supplied name. - */ - private String inferDepGraphDescription(String depGraphName) { - if (depGraphName.equals("initial")) { - return "Initially Live Code"; - } - - if (depGraphName.equals("total")) { - return "All Code"; - } - - Matcher matcher = PATTERN_SP_INT.matcher(depGraphName); - if (matcher.matches()) { - int splitPoint = Integer.valueOf(matcher.group(1)); - if (isInitialSplitPoint(splitPoint)) { - return "Code Becoming Live at Split Point " + splitPoint; - } else { - return "Code not Exclusive to Split Point " + splitPoint; - } - } - - throw new RuntimeException("Unexpected dependency graph name: " - + depGraphName); - } - - private boolean isInitialSplitPoint(int splitPoint) { - return globalInformation.getSplitPointInitialLoadSequence().contains( - splitPoint); - } - - private String makeCodeTypeHtml(SizeBreakdown breakdown, - Map<String, CodeCollection> nameToCodeColl, - Map<String, LiteralsCollection> nameToLitColl, String permutationId) - throws IOException { - String outFileName = breakdown.getId() + "-" + permutationId - + "_codeTypeBreakdown.html"; - float maxSize = 0f; - float sumSize = 0f; - TreeMap<Float, String> sortedCodeTypes = new TreeMap<Float, String>( - Collections.reverseOrder()); - - for (String codeType : nameToCodeColl.keySet()) { - float curSize = nameToCodeColl.get(codeType).getCumPartialSize(breakdown); - sumSize += curSize; - - if (curSize != 0f) { - sortedCodeTypes.put(curSize, codeType); - if (curSize > maxSize) { - maxSize = curSize; - } - } - } - - 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("<link rel=\"stylesheet\" href=\"common.css\" media=\"screen\">"); - outFile.println("</head>"); - - outFile.println("<body>"); - outFile.println("<table style='width:100%'>"); - outFile.println("<thead>"); - outFile.println("<th class='barlabel'>Size</th>"); - - outFile.println("<th class='barlabel'>Percentage</th>"); - outFile.println("<th class='barlabel'></th>"); - outFile.println("<th style='width:100%' class='barlabel'></th>"); - outFile.println("</thead>"); - - for (Float size : sortedCodeTypes.keySet()) { - - String codeType = sortedCodeTypes.get(size); - String drillDownFileName = breakdown.getId() + "_" + codeType + "-" - + permutationId + "Classes.html"; - - float ratio = (size / maxSize) * 79; - float perc = (size / sumSize) * 100; - - if (ratio < 5) { - ratio = 5; - } - - outFile.println("<tr>"); - outFile.println("<td class=\"barlabel\">" + size + "</td>"); - outFile.println("<td class=\"barlabel\">" + perc + "%</td>"); - outFile.println("<td class=\"barlabel\"><a href=\"" + drillDownFileName - + "\" target=\"_top\">" + codeType + "</a></td>"); - outFile.println("<td class=\"box\">"); - outFile.println("<div style=\"width:" - + ratio - + "%;\" class=\"lb\"><div class=\"rb\"><div class=\"bb\"><div class=\"blc\"><div class=\"brc\"><div class=\"tb\"><div class=\"tlc\"><div class=\"trc\"><div class=\"content\"></div></div></div></div></div></div></div></div>"); - outFile.println("</td>"); - outFile.println("</tr>"); - - } - - maxSize = 0f; - sumSize = 0f; - TreeMap<Float, String> sortedLitTypes = new TreeMap<Float, String>( - Collections.reverseOrder()); - - for (String literal : nameToLitColl.keySet()) { - float curSize = nameToLitColl.get(literal).size; - sumSize += curSize; - - if (curSize != 0f) { - sortedLitTypes.put(curSize, literal); - - if (curSize > maxSize) { - maxSize = curSize; - } - } - } - - for (Float size : sortedLitTypes.keySet()) { - String literal = sortedLitTypes.get(size); - String drillDownFileName = breakdown.getId() + "_" + literal + "-" - + permutationId + "Lits.html"; - - float ratio = (size / maxSize) * 79; - float perc = (size / sumSize) * 100; - - if (ratio < 5) { - ratio = 5; - } - - outFile.println("<tr>"); - outFile.println("<td class=\"barlabel\">" + size + "</td>"); - outFile.println("<td class=\"barlabel\">" + perc + "%</td>"); - outFile.println("<td class=\"barlabel\"><a href=\"" + drillDownFileName - + "\" target=\"_top\">" + literal + "</a></td>"); - outFile.println("<td class=\"box\">"); - outFile.println("<div style=\"width:" - + ratio - + "%;\" class=\"lb\"><div class=\"rb\"><div class=\"bb\"><div class=\"blc\"><div class=\"brc\"><div class=\"tb\"><div class=\"tlc\"><div class=\"trc\"><div class=\"content\"></div></div></div></div></div></div></div></div>"); - outFile.println("</td>"); - outFile.println("</tr>"); - - } - - outFile.println("</table>"); - outFile.println("</body>"); - outFile.println("</html>"); - outFile.close(); - - return outFileName; - } - - private static String shellFileName(SizeBreakdown breakdown, - String permutationId) { - return breakdown.getId() + "-" + permutationId + "-overallBreakdown.html"; + public GlobalInformation getGlobalInformation() { + return globalInformation; } public void makeBreakdownShell(SizeBreakdown breakdown, String permutationId) @@ -424,19 +282,20 @@ String inputFileName = "roundedCorners.css"; File inputFile = new File(classPath + RESOURCES_PATH + inputFileName); File outputFile = getOutFile("roundedCorners.css"); - copyFileOrDirectory(inputFile, outputFile, classPath, RESOURCES_PATH + inputFileName, false); + copyFileOrDirectory(inputFile, outputFile, classPath, RESOURCES_PATH + + inputFileName, false); inputFileName = "classLevel.css"; File inputFile2 = new File(classPath + RESOURCES_PATH + inputFileName); File outputFile2 = getOutFile("classLevel.css"); - copyFileOrDirectory(inputFile2, outputFile2, classPath, RESOURCES_PATH + inputFileName, - false); + copyFileOrDirectory(inputFile2, outputFile2, classPath, RESOURCES_PATH + + inputFileName, false); inputFileName = "common.css"; File inputFile3 = new File(classPath + RESOURCES_PATH + inputFileName); File outputFile3 = getOutFile("common.css"); - copyFileOrDirectory(inputFile3, outputFile3, classPath, RESOURCES_PATH + inputFileName, - false); + copyFileOrDirectory(inputFile3, outputFile3, classPath, RESOURCES_PATH + + inputFileName, false); inputFileName = "images"; File inputDir = new File(classPath + RESOURCES_PATH + "images"); @@ -855,7 +714,7 @@ outFile.println("<th class='barlabel'></th>"); outFile.println("<th style='width:100%' class='barlabel'></th>"); outFile.println("</thead>"); - +// for (Float size : sortedClasses.keySet()) { String className = sortedClasses.get(size); @@ -882,7 +741,6 @@ + "%;\" class=\"lb\"><div class=\"rb\"><div class=\"bb\"><div class=\"blc\"><div class=\"brc\"><div class=\"tb\"><div class=\"tlc\"><div class=\"trc\"><div class=\"content\"></div></div></div></div></div></div></div></div>"); outFile.println("</td>"); outFile.println("</tr>"); - } outFile.println("</table>"); outFile.println("</div>"); @@ -896,6 +754,45 @@ makeSplitStatusPage(className, permutationId); } } + + public void makeTopLevelHtmlForAllPerms() throws FileNotFoundException { + + PrintWriter outFile = new PrintWriter(getOutFile("index.html")); + + outFile.println("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">"); + outFile.println("<html>"); + outFile.println("<head>"); + outFile.println(" <title>Story of Your Compile - Top Level Dashboard for all Permutations</title>"); + outFile.println("<style type=\"text/css\">"); + outFile.println("body {background-color: #728FCE}"); + outFile.println("h2 {background-color: transparent}"); + outFile.println("</style>"); + outFile.println("</head>"); + + outFile.println("<body>"); + outFile.println("<center>"); + outFile.println("<h1>Story of Your Compile</h1>"); + outFile.println("<hr>"); + outFile.println("<h3>Story of Your Compile - Overview of Permutations</h3>"); + outFile.println("<hr>"); + + outFile.println("<div style='overflow:auto; background-color:white'>"); + outFile.println("<center>"); + for (String permutationId : settings.allPermsInfo.keySet()) { + String permutationInfo = settings.allPermsInfo.get(permutationId); + outFile.print("<p><a href=\"SoycDashboard" + "-" + permutationId + + "-index.html\">Permutation " + permutationId); + if (permutationInfo.length() > 0) { + outFile.println(" (" + permutationInfo + ")" + "</a>"); + } else { + outFile.println("</a>"); + } + } + outFile.println("</center>"); + outFile.println("</div>"); + addStandardHtmlEnding(outFile); + outFile.close(); + } public void makeTopLevelShell(String permutationId) throws IOException { PrintWriter outFile = new PrintWriter(getOutFile("SoycDashboard" + "-" @@ -1048,49 +945,12 @@ outFile.close(); } - private void addLefttoversStatus(String className, String packageName, - PrintWriter out, String permutationId) { - out.println("<tr><td> <a href=\"" - + dependenciesFileName("total", packageName, permutationId) + "#" - + className + "\">See why it's live</a></td></tr>"); - for (int sp = 1; sp <= globalInformation.getNumSplitPoints(); sp++) { - out.println("<tr><td> <a href=\"" - + dependenciesFileName("sp" + sp, packageName, permutationId) + "#" - + className + "\">See why it's not exclusive to s.p. #" + sp + " (" - + globalInformation.getSplitPointToLocation().get(sp) - + ")</a></td></tr>"); - } + public void setGlobalInformation(GlobalInformation globalInformation) { + this.globalInformation = globalInformation; } - private void addStandardHtmlEnding(final PrintWriter out) { - out.println("</div>"); - out.println("</body>"); - out.println("</html>"); - } - - private void addStandardHtmlProlog(final PrintWriter out, String title, - String header) { - out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\""); - out.println("\"http://www.w3.org/TR/html4/strict.dtd\">"); - out.println("<html>"); - out.println("<head>"); - out.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">"); - out.println("<title>" + title + "</title>"); - out.println("</head>"); - - out.println("<style type=\"text/css\">"); - out.println("body {background-color: #728FCE}"); - out.println("h2 {background-color: transparent}"); - out.println("p {background-color: fuchsia}"); - out.println("</style>"); - - out.println("<body>"); - out.println("<center>"); - out.println("<h2>" + title + "</h2>"); - if (header != null) { - addCenteredHeader(out, header); - } - out.println("</center>"); + public void setSettings(Settings settings) { + this.settings = settings; } private void addDependenciesHtmlProlog(final PrintWriter out, String title, @@ -1143,7 +1003,51 @@ addCenteredHeader(out, header); } out.println("</center>"); - + } + + private void addLefttoversStatus(String className, String packageName, + PrintWriter out, String permutationId) { + out.println("<tr><td> <a href=\"" + + dependenciesFileName("total", packageName, permutationId) + "#" + + className + "\">See why it's live</a></td></tr>"); + for (int sp = 1; sp <= globalInformation.getNumSplitPoints(); sp++) { + out.println("<tr><td> <a href=\"" + + dependenciesFileName("sp" + sp, packageName, permutationId) + "#" + + className + "\">See why it's not exclusive to s.p. #" + sp + " (" + + globalInformation.getSplitPointToLocation().get(sp) + + ")</a></td></tr>"); + } + } + + private void addStandardHtmlEnding(final PrintWriter out) { + out.println("</div>"); + out.println("</body>"); + out.println("</html>"); + } + + private void addStandardHtmlProlog(final PrintWriter out, String title, + String header) { + out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\""); + out.println("\"http://www.w3.org/TR/html4/strict.dtd\">"); + out.println("<html>"); + out.println("<head>"); + out.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">"); + out.println("<title>" + title + "</title>"); + out.println("</head>"); + + out.println("<style type=\"text/css\">"); + out.println("body {background-color: #728FCE}"); + out.println("h2 {background-color: transparent}"); + out.println("p {background-color: fuchsia}"); + out.println("</style>"); + + out.println("<body>"); + out.println("<center>"); + out.println("<h2>" + title + "</h2>"); + if (header != null) { + addCenteredHeader(out, header); + } + out.println("</center>"); } private String dependenciesFileName(String depGraphName, String packageName, @@ -1151,11 +1055,171 @@ return "methodDependencies-" + depGraphName + "-" + filename(packageName) + "-" + permutationId + ".html"; } + + /** + * Return a {...@link File} object for a file to be emitted into the output + * directory. + */ + private File getOutFile(String localFileName) { + File outDir = new File(settings.out.get()); + return new File(outDir, localFileName); + } + + /** + * Describe the code covered by the dependency graph with the supplied name. + */ + private String inferDepGraphDescription(String depGraphName) { + if (depGraphName.equals("initial")) { + return "Initially Live Code"; + } + + if (depGraphName.equals("total")) { + return "All Code"; + } + + Matcher matcher = PATTERN_SP_INT.matcher(depGraphName); + if (matcher.matches()) { + int splitPoint = Integer.valueOf(matcher.group(1)); + if (isInitialSplitPoint(splitPoint)) { + return "Code Becoming Live at Split Point " + splitPoint; + } else { + return "Code not Exclusive to Split Point " + splitPoint; + } + } + + throw new RuntimeException("Unexpected dependency graph name: " + + depGraphName); + } + + private boolean isInitialSplitPoint(int splitPoint) { + return globalInformation.getSplitPointInitialLoadSequence().contains( + splitPoint); + } private String leftoversStatusFileName(String className, String permutationId) { return "leftoverStatus-" + filename(className) + "-" + permutationId + ".html"; } + + private String makeCodeTypeHtml(SizeBreakdown breakdown, + Map<String, CodeCollection> nameToCodeColl, + Map<String, LiteralsCollection> nameToLitColl, String permutationId) + throws IOException { + String outFileName = breakdown.getId() + "-" + permutationId + + "_codeTypeBreakdown.html"; + float maxSize = 0f; + float sumSize = 0f; + TreeMap<Float, String> sortedCodeTypes = new TreeMap<Float, String>( + Collections.reverseOrder()); + + for (String codeType : nameToCodeColl.keySet()) { + float curSize = nameToCodeColl.get(codeType).getCumPartialSize(breakdown); + sumSize += curSize; + + if (curSize != 0f) { + sortedCodeTypes.put(curSize, codeType); + if (curSize > maxSize) { + maxSize = curSize; + } + } + } + + 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("<link rel=\"stylesheet\" href=\"common.css\" media=\"screen\">"); + outFile.println("</head>"); + + outFile.println("<body>"); + outFile.println("<table style='width:100%'>"); + outFile.println("<thead>"); + outFile.println("<th class='barlabel'>Size</th>"); + + outFile.println("<th class='barlabel'>Percentage</th>"); + outFile.println("<th class='barlabel'></th>"); + outFile.println("<th style='width:100%' class='barlabel'></th>"); + outFile.println("</thead>"); + + for (Float size : sortedCodeTypes.keySet()) { + + String codeType = sortedCodeTypes.get(size); + String drillDownFileName = breakdown.getId() + "_" + codeType + "-" + + permutationId + "Classes.html"; + + float ratio = (size / maxSize) * 79; + float perc = (size / sumSize) * 100; + + if (ratio < 5) { + ratio = 5; + } + + outFile.println("<tr>"); + outFile.println("<td class=\"barlabel\">" + size + "</td>"); + outFile.println("<td class=\"barlabel\">" + perc + "%</td>"); + outFile.println("<td class=\"barlabel\"><a href=\"" + drillDownFileName + + "\" target=\"_top\">" + codeType + "</a></td>"); + outFile.println("<td class=\"box\">"); + outFile.println("<div style=\"width:" + + ratio + + "%;\" class=\"lb\"><div class=\"rb\"><div class=\"bb\"><div class=\"blc\"><div class=\"brc\"><div class=\"tb\"><div class=\"tlc\"><div class=\"trc\"><div class=\"content\"></div></div></div></div></div></div></div></div>"); + outFile.println("</td>"); + outFile.println("</tr>"); + } + + maxSize = 0f; + sumSize = 0f; + TreeMap<Float, String> sortedLitTypes = new TreeMap<Float, String>( + Collections.reverseOrder()); + + for (String literal : nameToLitColl.keySet()) { + float curSize = nameToLitColl.get(literal).size; + sumSize += curSize; + + if (curSize != 0f) { + sortedLitTypes.put(curSize, literal); + + if (curSize > maxSize) { + maxSize = curSize; + } + } + } + + for (Float size : sortedLitTypes.keySet()) { + String literal = sortedLitTypes.get(size); + String drillDownFileName = breakdown.getId() + "_" + literal + "-" + + permutationId + "Lits.html"; + + float ratio = (size / maxSize) * 79; + float perc = (size / sumSize) * 100; + + if (ratio < 5) { + ratio = 5; + } + + outFile.println("<tr>"); + outFile.println("<td class=\"barlabel\">" + size + "</td>"); + outFile.println("<td class=\"barlabel\">" + perc + "%</td>"); + outFile.println("<td class=\"barlabel\"><a href=\"" + drillDownFileName + + "\" target=\"_top\">" + literal + "</a></td>"); + outFile.println("<td class=\"box\">"); + outFile.println("<div style=\"width:" + + ratio + + "%;\" class=\"lb\"><div class=\"rb\"><div class=\"bb\"><div class=\"blc\"><div class=\"brc\"><div class=\"tb\"><div class=\"tlc\"><div class=\"trc\"><div class=\"content\"></div></div></div></div></div></div></div></div>"); + outFile.println("</td>"); + outFile.println("</tr>"); + } + + outFile.println("</table>"); + outFile.println("</body>"); + outFile.println("</html>"); + outFile.close(); + + return outFileName; + } private void makeDependenciesHtml(String depGraphName, Map<String, String> dependencies, String permutationId) @@ -1300,7 +1364,6 @@ + "%;\" class=\"lb\"><div class=\"rb\"><div class=\"bb\"><div class=\"blc\"><div class=\"brc\"><div class=\"tb\"><div class=\"tlc\"><div class=\"trc\"><div class=\"content\"></div></div></div></div></div></div></div></div>"); outFile.println("</td>"); outFile.println("</tr>"); - } outFile.println("</table>"); @@ -1359,55 +1422,4 @@ private String splitStatusFileName(String className, String permutationId) { return "splitStatus-" + filename(className) + "-" + permutationId + ".html"; } - - public void makeTopLevelHtmlForAllPerms() throws FileNotFoundException { - - PrintWriter outFile = new PrintWriter(getOutFile("index.html")); - - outFile.println("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">"); - outFile.println("<html>"); - outFile.println("<head>"); - outFile.println(" <title>Story of Your Compile - Top Level Dashboard for all Permutations</title>"); - outFile.println("<style type=\"text/css\">"); - outFile.println("body {background-color: #728FCE}"); - outFile.println("h2 {background-color: transparent}"); - outFile.println("</style>"); - outFile.println("</head>"); - - outFile.println("<body>"); - outFile.println("<center>"); - outFile.println("<h1>Story of Your Compile</h1>"); - outFile.println("<hr>"); - outFile.println("<h3>Story of Your Compile - Overview of Permutations</h3>"); - outFile.println("<hr>"); - - outFile.println("<div style='overflow:auto; background-color:white'>"); - outFile.println("<center>"); - for (String permutationId : settings.allPermsInfo.keySet()) { - String permutationInfo = settings.allPermsInfo.get(permutationId); - outFile.print("<p><a href=\"SoycDashboard" + "-" + permutationId - + "-index.html\">Permutation " + permutationId); - if (permutationInfo.length() > 0) { - outFile.println(" (" + permutationInfo + ")" + "</a>"); - } else { - outFile.println("</a>"); - } - } - outFile.println("</center>"); - outFile.println("</div>"); - addStandardHtmlEnding(outFile); - outFile.close(); - } - - public GlobalInformation getGlobalInformation() { - return globalInformation; - } - - public void setGlobalInformation(GlobalInformation globalInformation) { - this.globalInformation = globalInformation; - } - - public void setSettings(Settings settings) { - this.settings = settings; - } -} +} ======================================= --- /trunk/tools/soyc-vis/src/com/google/gwt/soyc/Settings.java Mon Aug 17 07:08:53 2009 +++ /trunk/dev/core/src/com/google/gwt/soyc/Settings.java Fri Aug 21 10:48:30 2009 @@ -183,38 +183,30 @@ } return help.toString(); } + + public Map<String, String> allPermsInfo = new TreeMap<String, String>(); + public String depFileName; + public Boolean displayDependencies = false; + public Boolean displaySplitPoints = false; public final Setting<String> out = addSetting(new StringSetting("-out", "dir", ".", "output directory")); + public final Setting<String> resources = addSetting(new StringSetting( "-resources", "jarfile", null, " directory or jar file with CSS, etc., resources")); + public final Setting<String> soycDir = addSetting(new StringSetting( "-soycDir", "dir", null, " directory for soyc files")); - public final Setting<String> symbolMapsDir = addSetting(new StringSetting( - "-symbolMapsDir", "dir", null, " directory or symbol maps files")); - - public String depFileName; public String splitPointsFileName; public String storiesFileName; - private List<Setting<?>> allSettings; - - private <T> Setting<T> addSetting(Setting<T> setting) { - if (allSettings == null) { - allSettings = new ArrayList<Setting<?>>(); - } - allSettings.add(setting); - return setting; - } - - public Map<String, String> allPermsInfo = new TreeMap<String, String>(); - - public Boolean displayDependencies = false; - public Boolean displaySplitPoints = false; - + public final Setting<String> symbolMapsDir = addSetting(new StringSetting( + "-symbolMapsDir", "dir", null, " directory or symbol maps files")); + + private List<Setting<?>> allSettings; public void readPermutationInfo() throws FileNotFoundException { if (symbolMapsDir.get() == null) { @@ -253,5 +245,13 @@ } } } + + private <T> Setting<T> addSetting(Setting<T> setting) { + if (allSettings == null) { + allSettings = new ArrayList<Setting<?>>(); + } + allSettings.add(setting); + return setting; + } } ======================================= --- /trunk/tools/soyc-vis/src/com/google/gwt/soyc/SizeBreakdown.java Mon Aug 17 07:08:53 2009 +++ /trunk/dev/core/src/com/google/gwt/soyc/SizeBreakdown.java Fri Aug 21 10:48:30 2009 @@ -23,40 +23,15 @@ * A size breakdown of one code collection. */ public class SizeBreakdown { - private void initializeLiteralsCollection( - Map<String, LiteralsCollection> nameToLitColl) { - nameToLitColl.put("long", new LiteralsCollection()); - nameToLitColl.put("null", new LiteralsCollection()); - nameToLitColl.put("class", new LiteralsCollection()); - nameToLitColl.put("int", new LiteralsCollection()); - nameToLitColl.put("string", new LiteralsCollection()); - nameToLitColl.put("number", new LiteralsCollection()); - nameToLitColl.put("boolean", new LiteralsCollection()); - nameToLitColl.put("double", new LiteralsCollection()); - nameToLitColl.put("char", new LiteralsCollection()); - nameToLitColl.put("undefined", new LiteralsCollection()); - nameToLitColl.put("float", new LiteralsCollection()); - } - - private void initializeNameToCodeCollection( - HashMap<String, CodeCollection> nameToCodeColl) { - nameToCodeColl.put("allOther", new CodeCollection()); - nameToCodeColl.put("widget", new CodeCollection()); - nameToCodeColl.put("rpcUser", new CodeCollection()); - nameToCodeColl.put("rpcGen", new CodeCollection()); - nameToCodeColl.put("rpcGwt", new CodeCollection()); - nameToCodeColl.put("gwtLang", new CodeCollection()); - nameToCodeColl.put("jre", new CodeCollection()); - } - public Map<String, Integer> classToSize = new HashMap<String, Integer>(); + public HashMap<String, CodeCollection> nameToCodeColl = new HashMap<String, CodeCollection>(); + public Map<String, LiteralsCollection> nameToLitColl = new TreeMap<String, LiteralsCollection>(); public Map<String, Integer> packageToSize = new HashMap<String, Integer>(); - public int sizeAllCode; - private final String description; + private final String id; public SizeBreakdown(String description, String id) { @@ -66,7 +41,6 @@ initializeLiteralsCollection(nameToLitColl); initializeNameToCodeCollection(nameToCodeColl); } - /** * A short but human-readable description of this code collection. */ @@ -85,4 +59,30 @@ public String toString() { return getId(); } -} + + private void initializeLiteralsCollection( + Map<String, LiteralsCollection> nameToLitColl) { + nameToLitColl.put("long", new LiteralsCollection()); + nameToLitColl.put("null", new LiteralsCollection()); + nameToLitColl.put("class", new LiteralsCollection()); + nameToLitColl.put("int", new LiteralsCollection()); + nameToLitColl.put("string", new LiteralsCollection()); + nameToLitColl.put("number", new LiteralsCollection()); + nameToLitColl.put("boolean", new LiteralsCollection()); + nameToLitColl.put("double", new LiteralsCollection()); + nameToLitColl.put("char", new LiteralsCollection()); + nameToLitColl.put("undefined", new LiteralsCollection()); + nameToLitColl.put("float", new LiteralsCollection()); + } + + private void initializeNameToCodeCollection( + HashMap<String, CodeCollection> nameToCodeColl) { + nameToCodeColl.put("allOther", new CodeCollection()); + nameToCodeColl.put("widget", new CodeCollection()); + nameToCodeColl.put("rpcUser", new CodeCollection()); + nameToCodeColl.put("rpcGen", new CodeCollection()); + nameToCodeColl.put("rpcGwt", new CodeCollection()); + nameToCodeColl.put("gwtLang", new CodeCollection()); + nameToCodeColl.put("jre", new CodeCollection()); + } +} ======================================= --- /trunk/tools/soyc-vis/build.xml Mon Aug 17 13:34:09 2009 +++ /trunk/tools/soyc-vis/build.xml Fri Aug 21 10:48:30 2009 @@ -14,12 +14,6 @@ </target> <target name="compile"> - <mkdir dir="${javac.out}"/> - <javac srcdir="src" destdir="${javac.out}"> - <classpath> - <pathelement location="${gwt.dev.jar}" /> - </classpath> - </javac> <mkdir dir="${javac.out}/com/google/gwt/soyc/resources/images"/> <copy todir="${javac.out}/com/google/gwt/soyc/resources/images"> <fileset dir="images"/> @@ -30,12 +24,13 @@ </target> <target name="build" depends="compile"> - <gwt.jar> + <!-- Build a transitional jar that is good enough for + passing as -resources to SoycDashboard. This jar + is being phased out in favor of gwt-dev-platform.jar + holding all the SOYC bits. --> + <jar destfile="${project.lib}"> <fileset dir="${javac.out}" /> - <manifest> - <attribute name="Main-Class" value="com.google.gwt.soyc.SoycDashboard" /> - </manifest> - </gwt.jar> + </jar> </target> <target name="test"/> --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
