Added some css styling. git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@4341 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/tools/soyc-vis/build.xml b/tools/soyc-vis/build.xml index cbe1c15..c6d929d 100644 --- a/tools/soyc-vis/build.xml +++ b/tools/soyc-vis/build.xml
@@ -13,6 +13,12 @@ <target name="compile"> <mkdir dir="${javac.out}"/> <javac srcdir="src" destdir="${javac.out}"/> + <mkdir dir="${javac.out}/images"/> + <copy todir="${javac.out}/images"> + <fileset dir="images"/> + </copy> + <copy file="classLevel.css" tofile="${javac.out}/classLevel.css"/> + <copy file="roundedCorners.css" tofile="${javac.out}/roundedCorners.css"/> </target> <target name="build" depends="compile">
diff --git a/tools/soyc-vis/classLevel.css b/tools/soyc-vis/classLevel.css new file mode 100644 index 0000000..5c70a24 --- /dev/null +++ b/tools/soyc-vis/classLevel.css
@@ -0,0 +1,162 @@ +/* \*/ +* html #tlc, * html #trc {height: 1%;} +/* */ + +#tlc, #trc { zoom: 1 } + +h2 {background-color: transparent} +p {background-color: fuchsia} + A:link {text-decoration: none; color: blue;} +A:visited {text-decoration: none; color: blue;} +A:active {text-decoration: none} +A:hover {text-decoration: underline; color: maroon;} + +body + { + margin: 0; + padding: 0; + background-color: #728FCE; + font-size: 100.01%; + text-align: center; + } + +.box + { + position: absolute; + margin-left: 0; + margin-right: 0; + margin-top: 0; + margin-bottom: 0; + text-align: left; + <!--background-color: #eeeeee;--> + + z-index: 1; + opacity:0.7; + } + +.box-right + { + position: absolute; + margin-left: 0; + margin-right: 0; + margin-top: 0; + margin-bottom: 0; + text-align: right; + <!--background-color: #eeeeee;--> + z-index: 2; + opacity:0.7; + } + + +#content + { + height:25px; + } + + + +.barlabel { + + position: absolute; + font-size: 14px; + text-color: maroon; + z-index: 2; + <!--font-weight: bold;--> + text-align: left; + + +} + +#content h1 + { + color:#0354c2; + font-weight: bold; + font-size: 1.2em; + font-family: helvetica, geneva, arial, sans-serif; + } + +#content p + { + color:#3b3b3b; + font-size: 1em; + line-height: 1.3em; + font-family: arial, helvetica, sans-serif; + } + + + +/* ---=== border code follows ===--- */ +/* + tlc = top left corner + trc = top right corner + blc = bottom left corner + brc = bottom right corner + lb = left border + rb = right border + tb = top border + bb = bottom border +*/ + +#tlc, #trc, #blc, #brc + { + background-color: transparent; + background-repeat: no-repeat; + } + +#tlc + { + background-image:url(images/tlc.gif); + background-position: 0% 0%; + } + +#trc + { + background-image:url(images/trc.gif); + background-position: 100% 0%; + } + +#blc + { + background-image:url(images/blc.gif); + background-position: 0% 100%; + } + +#brc + { + background-image:url(images/brc.gif); + background-position: 100% 100%; + } + +#tb, #bb + { + background-color: transparent; + background-repeat: repeat-x; + } + +#tb + { + background-image:url(images/tb.gif); + background-position: 0% 0%; + } + +#bb + { + background-image:url(images/bb.gif); + background-position: 50% 100%; + } + +#rb + { + background-image:url(images/r.gif); + background-position: 100% 0%; + background-repeat: repeat-y; + } + +#lb + { + background-color: #eeeeee; + background-image:url(images/l.gif); + background-position: 0% 100%; + background-repeat: repeat-y; + } +
diff --git a/tools/soyc-vis/images/1bl.gif b/tools/soyc-vis/images/1bl.gif new file mode 100644 index 0000000..3183405 --- /dev/null +++ b/tools/soyc-vis/images/1bl.gif Binary files differ
diff --git a/tools/soyc-vis/images/1br.gif b/tools/soyc-vis/images/1br.gif new file mode 100644 index 0000000..8748c10 --- /dev/null +++ b/tools/soyc-vis/images/1br.gif Binary files differ
diff --git a/tools/soyc-vis/images/1tl.gif b/tools/soyc-vis/images/1tl.gif new file mode 100644 index 0000000..2ca18a7 --- /dev/null +++ b/tools/soyc-vis/images/1tl.gif Binary files differ
diff --git a/tools/soyc-vis/images/1tr.gif b/tools/soyc-vis/images/1tr.gif new file mode 100644 index 0000000..e4e2a96 --- /dev/null +++ b/tools/soyc-vis/images/1tr.gif Binary files differ
diff --git a/tools/soyc-vis/images/bb.gif b/tools/soyc-vis/images/bb.gif new file mode 100644 index 0000000..ef7d5a3 --- /dev/null +++ b/tools/soyc-vis/images/bb.gif Binary files differ
diff --git a/tools/soyc-vis/images/blc.gif b/tools/soyc-vis/images/blc.gif new file mode 100644 index 0000000..7b6d57a --- /dev/null +++ b/tools/soyc-vis/images/blc.gif Binary files differ
diff --git a/tools/soyc-vis/images/brc.gif b/tools/soyc-vis/images/brc.gif new file mode 100644 index 0000000..5afd529 --- /dev/null +++ b/tools/soyc-vis/images/brc.gif Binary files differ
diff --git a/tools/soyc-vis/images/l.gif b/tools/soyc-vis/images/l.gif new file mode 100644 index 0000000..a85da2c --- /dev/null +++ b/tools/soyc-vis/images/l.gif Binary files differ
diff --git a/tools/soyc-vis/images/r.gif b/tools/soyc-vis/images/r.gif new file mode 100644 index 0000000..4b8f639 --- /dev/null +++ b/tools/soyc-vis/images/r.gif Binary files differ
diff --git a/tools/soyc-vis/images/roundedbox_lo.gif b/tools/soyc-vis/images/roundedbox_lo.gif new file mode 100644 index 0000000..c614467 --- /dev/null +++ b/tools/soyc-vis/images/roundedbox_lo.gif Binary files differ
diff --git a/tools/soyc-vis/images/roundedbox_lu.gif b/tools/soyc-vis/images/roundedbox_lu.gif new file mode 100644 index 0000000..995bf88 --- /dev/null +++ b/tools/soyc-vis/images/roundedbox_lu.gif Binary files differ
diff --git a/tools/soyc-vis/images/roundedbox_ro.gif b/tools/soyc-vis/images/roundedbox_ro.gif new file mode 100644 index 0000000..8124e86 --- /dev/null +++ b/tools/soyc-vis/images/roundedbox_ro.gif Binary files differ
diff --git a/tools/soyc-vis/images/roundedbox_ru.gif b/tools/soyc-vis/images/roundedbox_ru.gif new file mode 100644 index 0000000..55774ef --- /dev/null +++ b/tools/soyc-vis/images/roundedbox_ru.gif Binary files differ
diff --git a/tools/soyc-vis/images/tb.gif b/tools/soyc-vis/images/tb.gif new file mode 100644 index 0000000..8b9a080 --- /dev/null +++ b/tools/soyc-vis/images/tb.gif Binary files differ
diff --git a/tools/soyc-vis/images/tlc.gif b/tools/soyc-vis/images/tlc.gif new file mode 100644 index 0000000..8c40bf7 --- /dev/null +++ b/tools/soyc-vis/images/tlc.gif Binary files differ
diff --git a/tools/soyc-vis/images/trc.gif b/tools/soyc-vis/images/trc.gif new file mode 100644 index 0000000..2e4ed5a --- /dev/null +++ b/tools/soyc-vis/images/trc.gif Binary files differ
diff --git a/tools/soyc-vis/roundedCorners.css b/tools/soyc-vis/roundedCorners.css new file mode 100644 index 0000000..567daf1 --- /dev/null +++ b/tools/soyc-vis/roundedCorners.css
@@ -0,0 +1,146 @@ +/* \*/ +* html #tlc, * html #trc {height: 1%;} +/* */ + +#tlc, #trc { zoom: 1 } + +h2 {background-color: transparent} +p {background-color: fuchsia} + A:link {text-decoration: none; color: blue;} +A:visited {text-decoration: none; color: blue;} +A:active {text-decoration: none} +A:hover {text-decoration: underline; color: maroon;} + +body + { + margin: 0; + padding: 0; + background-color: white; + font-size: 100.01%; + text-align: center; + } + +#box + { + position: absolute; + margin-left: 0; + margin-right: 0; + margin-top: 0; + margin-bottom: 0; + text-align: left; + <!--background-color: #eeeeee;--> + + z-index: 1; + opacity:0.7; + } + +#content + { + height:25px; + } + +.barlabel { + + position: absolute; + font-size: 14px; + text-color: maroon; + z-index: 2; + <!--font-weight: bold;--> + text-align: left; + + +} + +#content h1 + { + color:#0354c2; + font-weight: bold; + font-size: 1.2em; + font-family: helvetica, geneva, arial, sans-serif; + } + +#content p + { + color:#3b3b3b; + font-size: 1em; + line-height: 1.3em; + font-family: arial, helvetica, sans-serif; + } + + + +/* ---=== border code follows ===--- */ +/* + tlc = top left corner + trc = top right corner + blc = bottom left corner + brc = bottom right corner + lb = left border + rb = right border + tb = top border + bb = bottom border +*/ + +#tlc, #trc, #blc, #brc + { + background-color: transparent; + background-repeat: no-repeat; + } + +#tlc + { + background-image:url(images/tlc.gif); + background-position: 0% 0%; + } + +#trc + { + background-image:url(images/trc.gif); + background-position: 100% 0%; + } + +#blc + { + background-image:url(images/blc.gif); + background-position: 0% 100%; + } + +#brc + { + background-image:url(images/brc.gif); + background-position: 100% 100%; + } + +#tb, #bb + { + background-color: transparent; + background-repeat: repeat-x; + } + +#tb + { + background-image:url(images/tb.gif); + background-position: 0% 0%; + } + +#bb + { + background-image:url(images/bb.gif); + background-position: 50% 100%; + } + +#rb + { + background-image:url(images/r.gif); + background-position: 100% 0%; + background-repeat: repeat-y; + } + +#lb + { + background-color: #eeeeee; + background-image:url(images/l.gif); + background-position: 0% 100%; + background-repeat: repeat-y; + } +
diff --git a/tools/soyc-vis/src/com/google/gwt/soyc/CodeCollection.java b/tools/soyc-vis/src/com/google/gwt/soyc/CodeCollection.java index 6575008..655b516 100644 --- a/tools/soyc-vis/src/com/google/gwt/soyc/CodeCollection.java +++ b/tools/soyc-vis/src/com/google/gwt/soyc/CodeCollection.java
@@ -25,11 +25,12 @@ public TreeSet<String> stories = new TreeSet<String>(); public float cumPartialSize = 0f; public int cumSize = 0; + + public CodeCollection(String type){ codeType = type; } - public int getCumSize(){ cumSize = 0; for (String className : classes){
diff --git a/tools/soyc-vis/src/com/google/gwt/soyc/GlobalInformation.java b/tools/soyc-vis/src/com/google/gwt/soyc/GlobalInformation.java index d7d23f5..47c9c25 100644 --- a/tools/soyc-vis/src/com/google/gwt/soyc/GlobalInformation.java +++ b/tools/soyc-vis/src/com/google/gwt/soyc/GlobalInformation.java
@@ -23,36 +23,36 @@ import java.util.TreeSet; public class GlobalInformation { - - public static HashMap<String, HashSet<String>> storiesToCorrClasses = new HashMap<String, HashSet<String>>(); - public static HashMap<String, String> storiesToLitType = new HashMap<String, String>(); - public static HashMap<String, Integer> packageToSize = new HashMap<String, Integer>(); - public static HashMap<String, Float> packageToPartialSize = new HashMap<String, Float>(); - + public static int allOtherFragmentsPartialSize = 0; public static HashMap<String, String> classToPackage = new HashMap<String, String>(); - + public static HashMap<String, Float> classToPartialSize = new HashMap<String, Float>(); + public static HashMap<String, Integer> classToSize = new HashMap<String, Integer>(); //TODO(kprobst): not currently used, but will be for dependencies public static HashMap<String, HashSet<String>> classToWhatItDependsOn = new HashMap<String, HashSet<String>>(); - - public static HashMap<String, Integer> classToSize = new HashMap<String, Integer>(); - public static HashMap<String, Float> classToPartialSize = new HashMap<String, Float>(); - public static TreeMap<String, TreeSet<String>> packageToClasses = new TreeMap<String, TreeSet<String>>(); - - public static HashSet<String> nonAttributedStories = new HashSet<String>(); - public static int nonAttributedBytes = 0; - public static int numBytesDoubleCounted = 0; - - public static int cumSizeAllCode = 0; public static float cumPartialSizeFromPackages = 0f; + public static int cumSizeAllCode = 0; public static int cumSizeFromPackages = 0; - + public static int cumSizeInitialFragment = 0; + public static HashMap<Integer, Float> fragmentToPartialSize = new HashMap<Integer, Float>(); //collect only size for exclusive fragments public static HashMap<Integer, HashSet<String>> fragmentToStories = new HashMap<Integer, HashSet<String>>(); - public static HashMap<Integer, Float> fragmentToPartialSize = new HashMap<Integer, Float>(); + public static TreeMap<String, LiteralsCollection> nameToLitColl = new TreeMap<String, LiteralsCollection>(); + public static HashMap<String, CodeCollection> nameToCodeColl = new HashMap<String, CodeCollection>(); + + + public static int nonAttributedBytes = 0; + public static HashSet<String> nonAttributedStories = new HashSet<String>(); + public static int numBytesDoubleCounted = 0; public static int numFragments = 0; public static int numSplitPoints = 0; - public static int cumSizeInitialFragment = 0; - + public static TreeMap<String, TreeSet<String>> packageToClasses = new TreeMap<String, TreeSet<String>>(); + public static HashMap<String, Float> packageToPartialSize = new HashMap<String, Float>(); + public static HashMap<String, Integer> packageToSize = new HashMap<String, Integer>(); + public static HashMap<Integer, String> splitPointToLocation = new HashMap<Integer, String>(); + public static HashMap<String, HashSet<String>> storiesToCorrClasses = new HashMap<String, HashSet<String>>(); + public static HashMap<String, HashSet<String>> storiesToCorrClassesAndMethods = new HashMap<String, HashSet<String>>(); + + public static HashMap<String, String> storiesToLitType = new HashMap<String, String>(); public static void computePackageSizes(){ cumSizeFromPackages = 0; packageToSize.clear(); @@ -71,7 +71,6 @@ } } } - public static void computePartialPackageSizes(){ cumPartialSizeFromPackages = 0; packageToPartialSize.clear();
diff --git a/tools/soyc-vis/src/com/google/gwt/soyc/LiteralsCollection.java b/tools/soyc-vis/src/com/google/gwt/soyc/LiteralsCollection.java index ce17b5d..3f71ef1 100644 --- a/tools/soyc-vis/src/com/google/gwt/soyc/LiteralsCollection.java +++ b/tools/soyc-vis/src/com/google/gwt/soyc/LiteralsCollection.java
@@ -22,18 +22,21 @@ import java.util.TreeMap; public class LiteralsCollection { + public int cumSize = 0; + public int cumStringSize = 0; public String literalType = ""; public Map<String, HashSet<String>> literalToLocations = new TreeMap<String, HashSet<String>>(); public Map<String, HashSet<String> > storyToLocations = new HashMap<String, HashSet<String>>(); public TreeMap<String, String> stringLiteralToType = new TreeMap<String, String>(); public Map<String, Integer> stringTypeToSize = new HashMap<String, Integer>(); public Map<String, Integer> stringTypeToCount = new HashMap<String, Integer>(); - public int cumSize = 0; - public int cumStringSize = 0; + /** + * constructor + */ public LiteralsCollection(String type){ literalType = type; - } + } /** * Utility method
diff --git a/tools/soyc-vis/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java b/tools/soyc-vis/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java index e5f66d3..7de2f8f 100644 --- a/tools/soyc-vis/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java +++ b/tools/soyc-vis/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java
@@ -16,131 +16,21 @@ package com.google.gwt.soyc; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.io.PrintWriter; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.TreeMap; +import java.util.TreeSet; public class MakeTopLevelHtmlForPerm { - public static void makeHTMLShell(HashMap<String, CodeCollection> nameToCodeColl, TreeMap<String, LiteralsCollection> nameToLitColl) throws IOException{ - //this will contain the place holder iframes where the actual information is going to go. - - String fileName = "SoycDashboard-index.html"; - - final PrintWriter outFile = new PrintWriter(fileName); - 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 Permutation</title>"); - - 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("</style>"); - outFile.println("</head>"); - - - outFile.println("<body>"); - outFile.println("<center>"); - outFile.println("<h3>Story of Your Compile Dashboard</h3>"); - outFile.println("<hr>"); - if (GlobalInformation.cumSizeInitialFragment != 0){ - outFile.println("<b>Full code size: <span style=\"color:maroon\">" + GlobalInformation.cumSizeAllCode + "</span>, Size of Initial Download: <span style=\"color:maroon\">" + GlobalInformation.cumSizeInitialFragment + "</span></b>"); - } - else{ - outFile.println("<b>Full code size: <span style=\"color:maroon\">" + GlobalInformation.cumSizeAllCode + "</span></b>"); - } - outFile.println("</center>"); - outFile.println(" <div style=\"width:50%; float:left; padding-top: 10px;\">"); - outFile.println("<b>Package breakdown</b>"); - outFile.println(" </div>"); - outFile.println(" <div style=\"width:48%; float:right; padding-top: 10px; \">"); - outFile.println("<b>Code type breakdown</b>"); - outFile.println(" </div>"); - - - outFile.println(" <div style=\"width:50%; float:left; padding-top: 10px;\">"); - outFile.println("<div style=\"width: 110px; float: left; font-size:16px;\">Size</div>"); - outFile.println("<div style=\"width: 200px; float: left; text-align:left; font-size:16px; \">Package Name</div>"); - outFile.println(" </div>"); - - - outFile.println(" <div style=\"width:48%; float:right; padding-top: 10px;\">"); - outFile.println("<div style=\"width: 110px; float: left; font-size:16px;\">Size</div>"); - outFile.println("<div style=\"width: 200px; float: left; text-align:left; font-size:16px; \">Code Type</div>"); - outFile.println(" </div>"); - - - - outFile.println("<div style=\"height:35%; width:48%; margin:0 auto; background-color:white; float:left;\">"); - outFile.println("<iframe src=\"packageBreakdown.html\" width=100% height=100% scrolling=auto></iframe>"); - outFile.println(" </div>"); - makePackageHtml("packageBreakdown.html"); - - outFile.println("<div style=\"height:35%; width:48%; margin:0 auto; background-color:white; float:right;\">"); - outFile.println("<iframe src=\"codeTypeBreakdown.html\" width=100% height=100% scrolling=auto></iframe>"); - outFile.println(" </div>"); - makeCodeTypeHtml("codeTypeBreakdown.html", nameToCodeColl); - - outFile.println(" <div style=\"width:50%; float:left; padding-top: 10px;\">"); - outFile.println("<b>Literals breakdown</b>"); - outFile.println(" </div>"); - outFile.println(" <div style=\"width:48%; float:right; padding-top: 10px; \">"); - outFile.println("<b>String literals breakdown</b>"); - outFile.println(" </div>"); - - - outFile.println(" <div style=\"width:50%; float:left; padding-top: 10px;\">"); - outFile.println("<div style=\"width: 110px; float: left; font-size:16px;\">Size</div>"); - outFile.println("<div style=\"width: 200px; float: left; text-align:left; font-size:16px; \">Literal Type</div>"); - outFile.println(" </div>"); - - - outFile.println(" <div style=\"width:48%; float:right; padding-top: 10px; \">"); - outFile.println("<div style=\"width: 110px; float: left; font-size:16px;\">Size</div>"); - outFile.println("<div style=\"width: 200px; float: left; text-align:left; font-size:16px; \">String Literal Type</div>"); - outFile.println(" </div>"); - - - outFile.println("<div style=\"height:35%; width:48%; margin:0 auto; background-color:white; float:left;\">"); - outFile.println("<iframe src=\"literalsBreakdown.html\" width=100% height=100% scrolling=auto></iframe>"); - outFile.println("</div>"); - makeLiteralsHtml("literalsBreakdown.html", nameToLitColl); - - outFile.println("<div style=\"height:35%; width:48%; margin:0 auto; background-color:white; float:right;\">"); - outFile.println("<iframe src=\"stringLiteralsBreakdown.html\" width=100% height=100% scrolling=auto></iframe>"); - outFile.println(" </div>"); - makeStringLiteralsHtml("stringLiteralsBreakdown.html", nameToLitColl); - - - - if (GlobalInformation.fragmentToStories.size() != 1){ - outFile.println(" <div style=\"width:100%; float:left; padding-top: 10px;\">"); - outFile.println("<b>Fragments breakdown</b>"); - outFile.println(" </div>"); - - outFile.println(" <div style=\"width:100%; float:left; padding-top: 10px;\">"); - outFile.println("<div style=\"width: 110px; float: left; font-size:16px;\">Size</div>"); - outFile.println("<div style=\"width: 200px; float: left; text-align:left; font-size:16px; \">Fragment Name</div>"); - outFile.println(" </div>"); - - outFile.println("<div style=\"height:35%; width:50%; margin:0 auto; background-color:white; float:left;\">"); - outFile.println("<iframe src=\"fragmentsBreakdown.html\" width=100% height=100% scrolling=auto></iframe>"); - outFile.println("</div>"); - makeFragmentsHtml("fragmentsBreakdown.html"); - } - - outFile.println(" </body>"); - outFile.println("</html>"); - outFile.close(); - - } - - private static void makePackageHtml(String outFileName) throws IOException{ @@ -163,6 +53,7 @@ outFile.println("<head>"); outFile.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">"); outFile.println("<link rel=\"stylesheet\" href=\"roundedCorners.css\" media=\"screen\">"); + outFile.println("</head>"); outFile.println("<body>"); @@ -206,19 +97,47 @@ } - private static void makeFragmentsHtml(String outFileName) throws IOException{ - TreeMap<Float, Integer> sortedFragments = new TreeMap<Float, Integer>(Collections.reverseOrder()); + // TreeMap<Float, Integer> sortedFragments = new TreeMap<Float, Integer>(Collections.reverseOrder()); + TreeMap<Float, String> sortedSplitPoints = new TreeMap<Float, String>(Collections.reverseOrder()); float maxSize = 0f; float sumSize = 0f; - for (Integer fragmentName : GlobalInformation.fragmentToPartialSize.keySet()){ + + // initial fragment + float initialSize = GlobalInformation.fragmentToPartialSize.get(0); + sumSize += initialSize; + maxSize = initialSize; + sortedSplitPoints.put(initialSize, "initialDownload"); + + // all fragments that are not in the initial load order + float allOtherFragmentsSize = GlobalInformation.allOtherFragmentsPartialSize; + sumSize += allOtherFragmentsSize; + if (allOtherFragmentsSize > maxSize){ + maxSize = allOtherFragmentsSize; + } + sortedSplitPoints.put(allOtherFragmentsSize, "allOtherFragments"); + + // all exclusive fragments + System.out.println(""); + for (Integer splitPointId : GlobalInformation.splitPointToLocation.keySet()){ + System.out.println("splitPointId is: " + splitPointId); + Float sizeOfCurExclusiveFrag = GlobalInformation.fragmentToPartialSize.get(splitPointId); + sortedSplitPoints.put(sizeOfCurExclusiveFrag, GlobalInformation.splitPointToLocation.get(splitPointId)); + sumSize += sizeOfCurExclusiveFrag; + if (sizeOfCurExclusiveFrag > maxSize){ + maxSize = sizeOfCurExclusiveFrag; + } + } + + +/* for (Integer fragmentName : GlobalInformation.fragmentToPartialSize.keySet()){ sortedFragments.put(GlobalInformation.fragmentToPartialSize.get(fragmentName), fragmentName); sumSize += GlobalInformation.fragmentToPartialSize.get(fragmentName); if (GlobalInformation.fragmentToPartialSize.get(fragmentName) > maxSize){ maxSize = GlobalInformation.fragmentToPartialSize.get(fragmentName); } - } + }*/ final PrintWriter outFile = new PrintWriter(outFileName); @@ -232,10 +151,13 @@ outFile.println("<body>"); int yOffset = 0; - for (Float size : sortedFragments.keySet()){ - - Integer fragmentName = sortedFragments.get(size); - String drillDownFileName = "fragment" + Integer.toString(fragmentName) + "Classes.html"; + //for (Float size : sortedFragments.keySet()){ + for (Float size : sortedSplitPoints.keySet()){ + + // Integer fragmentName = sortedFragments.get(size); + String splitPointName = sortedSplitPoints.get(size); + // String drillDownFileName = "fragment" + Integer.toString(fragmentName) + "Classes.html"; + String drillDownFileName = "splitPoint" + splitPointName + "Classes.html"; float ratio = (size / maxSize) * 79; @@ -260,8 +182,9 @@ outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText + "px; left:5px;\">%.1f</div>\n", size); outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText + "px; left:80px;\">%.1f", perc); outFile.println("%</div>\n"); - outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText + "px; left:120px;\"><a href=\"" + drillDownFileName + "\" target=\"_top\">fragment"+ Integer.toString(fragmentName) +"</a></div>"); - + // outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText + "px; left:120px;\"><a href=\"" + drillDownFileName + "\" target=\"_top\">fragment"+ Integer.toString(fragmentName) +"</a></div>"); + outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText + "px; left:120px;\"><a href=\"" + drillDownFileName + "\" target=\"_top\">"+ splitPointName +"</a></div>"); + yOffset = yOffset + 25; } @@ -270,10 +193,7 @@ outFile.close(); } - - - private static void makeCodeTypeHtml(String outFileName, HashMap<String, CodeCollection> nameToCodeColl) throws IOException{ @@ -345,8 +265,6 @@ } - - private static void makeLiteralsHtml(String outFileName, TreeMap<String, LiteralsCollection> nameToLitColl) throws IOException{ @@ -418,7 +336,6 @@ } - private static void makeStringLiteralsHtml(String outFileName, TreeMap<String, LiteralsCollection> nameToLitColl) throws IOException{ final PrintWriter outFile = new PrintWriter(outFileName); @@ -499,137 +416,44 @@ outFile.close(); } - - - public static void makePackageClassesHtmls() throws IOException{ - - for (String packageName : GlobalInformation.packageToClasses.keySet()){ - - String outFileName = packageName + "Classes.html"; - TreeMap<Float, String> sortedClasses = new TreeMap<Float, String>(Collections.reverseOrder()); - float maxSize = 0f; - - //TODO(kprobst): not currently used, but will be for dependencies - int maxDepCount = 1; - - for (String className : GlobalInformation.packageToClasses.get(packageName)){ - - float curSize = 0f; - if (! GlobalInformation.classToPartialSize.containsKey(className)){ - System.err.println("*** NO PARTIAL SIZE FOUND FOR CLASS " + className + " *****"); - } - else{ - curSize = GlobalInformation.classToPartialSize.get(className); - } - - //TODO(kprobst): not currently used, but will be for dependencies - int depCount = 0; - if (GlobalInformation.classToWhatItDependsOn.containsKey(className)){ - depCount = GlobalInformation.classToWhatItDependsOn.get(className).size(); - } - - if (curSize != 0f){ - - sortedClasses.put(curSize, className); - if (curSize > maxSize){ - maxSize = curSize; - } - //TODO(kprobst): not currently used, but will be for dependencies - if (depCount > maxDepCount){ - maxDepCount = depCount; - } - } + public static void copyFileOrDirectory(File srcPath, File dstPath) throws IOException{ + if (srcPath.isDirectory()){ + if (!dstPath.exists()){ + dstPath.mkdir(); + } + String files[] = srcPath.list(); + for(int i = 0; i < files.length; i++){ + copyFileOrDirectory(new File(srcPath, files[i]), new File(dstPath, files[i])); } - - - final PrintWriter outFile = new PrintWriter(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=\"classLevel.css\" media=\"screen\">"); - outFile.println("<title>Classes in package \"" + packageName + "\"</title>"); - outFile.println("</head>"); - outFile.println("<body>"); - - - outFile.println("<center>"); - outFile.println("<h2>Classes in package \"" + packageName + "\"</h2>"); - outFile.println("</center>"); - outFile.println("<hr>"); - - outFile.println("<div style=\"width:90%; height:80%; overflow-y:auto; overflow-x:auto; top: 90px; left:70px; position:absolute; background-color:white\""); - - - int yOffset = 0; - for (Float size : sortedClasses.keySet()){ - - String className = sortedClasses.get(size); - - //TODO(kprobst): switch out the commented/uncommented lines below when showing dependencies - float ratio = (size / maxSize) * 45; - //float ratio = (size / maxSize) * 85; - - if (ratio < 3){ - ratio = 3; - } - - //TODO(kprobst): not currently used, but will be for dependencies - // get the dependency count - int depCount = 0; - if (GlobalInformation.classToWhatItDependsOn.containsKey(className)){ - depCount = GlobalInformation.classToWhatItDependsOn.get(className).size(); - } - float depRatio = ((float)depCount / (float)maxDepCount) * 45f; - if (depRatio < 3.0){ - depRatio = 3; - } - - outFile.println("<div class=\"box\" style=\"width:" + ratio + "%; top: " + yOffset + "px; left: 60px;\">"); - outFile.println("<div id=\"lb\">"); - outFile.println("<div id=\"rb\">"); - outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">"); - outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">"); - outFile.println("<div id=\"content\">"); - outFile.println("</div>"); - outFile.println("</div></div></div></div>"); - outFile.println("</div></div></div></div>"); - outFile.println("</div>"); - - - //TODO(kprobst): not currently used, but will be for dependencies - // place holder for mock-up of dependency display - outFile.println("<div class=\"box-right\" style=\"width:" + depRatio + "%; top: " + yOffset + "px; left: 50%\">"); - outFile.println("<div id=\"lb\">"); - outFile.println("<div id=\"rb\">"); - outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">"); - outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">"); - outFile.println("<div id=\"content\">"); - outFile.println("</div>"); - outFile.println("</div></div></div></div>"); - outFile.println("</div></div></div></div>"); - outFile.println("</div>"); - - int yOffsetText = yOffset+8; - outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText + "px; left:5px;\">%.1f</div>\n", size); - outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText + "px; left:70px;\">"+className+"</div>"); - //TODO(kprobst) make this a link - String drillDownFileName = className + "Deps.html"; - outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText + "px; left:50%;\"><a href=\"" + drillDownFileName + "\" target=\"_top\">Dependencies: " + depCount + "</a></div>"); - - yOffset = yOffset + 25; - - } - - outFile.println("</div>"); - outFile.println("</body>"); - outFile.println("</html>"); - outFile.close(); } + else{ + if(!srcPath.exists()){ + System.out.println("File or directory does not exist."); + System.exit(0); + } + else{ + InputStream in = new FileInputStream(srcPath); + OutputStream out = new FileOutputStream(dstPath); + // Transfer bytes from in to out + byte[] buf = new byte[1024]; + int len; + while ((len = in.read(buf)) > 0) { + out.write(buf, 0, len); + } + in.close(); + out.close(); + } + } } - + + public static String escapeXml(String unescaped) { + String escaped = unescaped.replaceAll("\\&", "&"); + escaped = escaped.replaceAll("\\<", "<"); + escaped = escaped.replaceAll("\\>", ">"); + escaped = escaped.replaceAll("\\\"", """); + escaped = escaped.replaceAll("\\'", "'"); + return escaped; + } public static void makeCodeTypeClassesHtmls(HashMap<String, CodeCollection> nameToCodeColl) throws IOException{ @@ -643,7 +467,7 @@ TreeMap<Float, String> sortedClasses = new TreeMap<Float, String>(Collections.reverseOrder()); for (String className : nameToCodeColl.get(codeType).classes){ if (GlobalInformation.classToPartialSize.containsKey(className)){ - + float curSize = 0f; if (! GlobalInformation.classToPartialSize.containsKey(className)){ System.err.println("*** NO PARTIAL SIZE FOUND FOR CLASS " + className + " *****"); @@ -667,7 +491,7 @@ outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\">"); outFile.println("<html>"); outFile.println("<head>"); - + outFile.println("<style type=\"text/css\">"); outFile.println("body {background-color: #728FCE}"); outFile.println("h2 {background-color: transparent}"); @@ -680,15 +504,15 @@ outFile.println("</head>"); outFile.println("<body>"); - - + + outFile.println("<center>"); outFile.println("<h2>Classes of type \"" + codeType + "\"</h2>"); outFile.println("</center>"); outFile.println("<hr>"); - + outFile.println("<div style=\"width:90%; height:80%; overflow-y:auto; overflow-x:auto; top: 90px; left:70px; position:absolute; background-color:white\""); - + int yOffset = 0; for (Float size : sortedClasses.keySet()){ @@ -727,6 +551,262 @@ } } + public static void makeDependenciesTableHtmls() throws IOException{ + + for (String className : GlobalInformation.classToWhatItDependsOn.keySet()){ + + String outFileName = className + "Deps.html"; + final PrintWriter outFile = new PrintWriter(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 that \"" + className + "\" depends on</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("</style>"); + + outFile.println("<body>"); + outFile.println("<center>"); + outFile.println("<h2>Classes that \"" + className + "\" depends on</h2>"); + outFile.println("</center>"); + outFile.println("<hr>"); + + outFile.println("<center>"); + outFile.println("<table border=\"1\" width=\"80%\" style=\"font-size: 11pt;\" bgcolor=\"white\">"); + + for (String depClassName : GlobalInformation.classToWhatItDependsOn.get(className)){ + + outFile.println("<tr>"); + outFile.println("<td width=\"80%\">" + depClassName + "</td>"); + outFile.println("</tr>"); + + } + + outFile.println("</table>"); + outFile.println("<center>"); + + outFile.println("</div>"); + 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 + * @throws IOException + */ + public static void makeFragmentClassesHtmls() throws IOException{ + + + for (Integer fragmentName : GlobalInformation.fragmentToStories.keySet()){ + HashSet<String> alreadyPrintedClasses = new HashSet<String>(); + + String outFileName = "fragment" + Integer.toString(fragmentName) + "Classes.html"; + + final PrintWriter outFile = new PrintWriter(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 correlated with fragment " + Integer.toString(fragmentName) + " </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;/*cellspacing:poor IE support for this*/"); + outFile.println("border-collapse:separate;"); + outFile.println("}"); + outFile.println(".celldiv {"); + outFile.println("float:left;/*fix for buggy browsers*/"); + 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 correlated with fragment " + Integer.toString(fragmentName) + "</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\">"); + + for (String storyName : GlobalInformation.fragmentToStories.get(fragmentName)){ + if (GlobalInformation.storiesToCorrClasses.containsKey(storyName)){ + for (String className : GlobalInformation.storiesToCorrClasses.get(storyName)){ + + if (! alreadyPrintedClasses.contains(className)){ + //outFile.println("<div class=\"rowdiv\">"); + outFile.println("<div class=\"rowdiv\">" + className + "</div>"); + //outFile.println("</div>"); + alreadyPrintedClasses.add(className); + } + } + } + } + outFile.println("</div>"); + outFile.println("</body>"); + outFile.println("</html>"); + outFile.close(); + } + } + + public static void makeHTMLShell(HashMap<String, CodeCollection> nameToCodeColl, TreeMap<String, LiteralsCollection> nameToLitColl) throws IOException{ + //this will contain the place holder iframes where the actual information is going to go. + + // copy from the bin directory to the current directory + String classPath = System.getProperty("java.class.path"); + if (!classPath.endsWith("/")){ + classPath += "/"; + } + File inputFile = new File(classPath + "roundedCorners.css"); + File outputFile = new File("roundedCorners.css"); + copyFileOrDirectory(inputFile, outputFile); + + File inputFile2 = new File(classPath + "classLevel.css"); + File outputFile2 = new File("classLevel.css"); + copyFileOrDirectory(inputFile2, outputFile2); + + File inputDir = new File(classPath + "images"); + File outputDir = new File("images"); + copyFileOrDirectory(inputDir, outputDir); + + + String fileName = "SoycDashboard-index.html"; + + final PrintWriter outFile = new PrintWriter(fileName); + 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 Permutation</title>"); + + 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("</style>"); + outFile.println("</head>"); + + + outFile.println("<body>"); + outFile.println("<center>"); + outFile.println("<h3>Story of Your Compile Dashboard</h3>"); + outFile.println("<hr>"); + if (GlobalInformation.fragmentToStories.size() > 1){ + outFile.println("<b>Full code size: <span style=\"color:maroon\">" + GlobalInformation.cumSizeAllCode + "</span>, Size of Initial Download: <span style=\"color:maroon\">" + GlobalInformation.fragmentToPartialSize.get(0) + "</span></b>"); + } + else{ + outFile.println("<b>Full code size: <span style=\"color:maroon\">" + GlobalInformation.cumSizeAllCode + "</span></b>"); + } + outFile.println("</center>"); + outFile.println(" <div style=\"width:50%; float:left; padding-top: 10px;\">"); + outFile.println("<b>Package breakdown</b>"); + outFile.println(" </div>"); + outFile.println(" <div style=\"width:48%; float:right; padding-top: 10px; \">"); + outFile.println("<b>Code type breakdown</b>"); + outFile.println(" </div>"); + + + outFile.println(" <div style=\"width:50%; float:left; padding-top: 10px;\">"); + outFile.println("<div style=\"width: 110px; float: left; font-size:16px;\">Size</div>"); + outFile.println("<div style=\"width: 200px; float: left; text-align:left; font-size:16px; \">Package Name</div>"); + outFile.println(" </div>"); + + + outFile.println(" <div style=\"width:48%; float:right; padding-top: 10px;\">"); + outFile.println("<div style=\"width: 110px; float: left; font-size:16px;\">Size</div>"); + outFile.println("<div style=\"width: 200px; float: left; text-align:left; font-size:16px; \">Code Type</div>"); + outFile.println(" </div>"); + + + + outFile.println("<div style=\"height:35%; width:48%; margin:0 auto; background-color:white; float:left;\">"); + outFile.println("<iframe src=\"packageBreakdown.html\" width=100% height=100% scrolling=auto></iframe>"); + outFile.println(" </div>"); + makePackageHtml("packageBreakdown.html"); + + outFile.println("<div style=\"height:35%; width:48%; margin:0 auto; background-color:white; float:right;\">"); + outFile.println("<iframe src=\"codeTypeBreakdown.html\" width=100% height=100% scrolling=auto></iframe>"); + outFile.println(" </div>"); + makeCodeTypeHtml("codeTypeBreakdown.html", nameToCodeColl); + + outFile.println(" <div style=\"width:50%; float:left; padding-top: 10px;\">"); + outFile.println("<b>Literals breakdown</b>"); + outFile.println(" </div>"); + outFile.println(" <div style=\"width:48%; float:right; padding-top: 10px; \">"); + outFile.println("<b>String literals breakdown</b>"); + outFile.println(" </div>"); + + + outFile.println(" <div style=\"width:50%; float:left; padding-top: 10px;\">"); + outFile.println("<div style=\"width: 110px; float: left; font-size:16px;\">Size</div>"); + outFile.println("<div style=\"width: 200px; float: left; text-align:left; font-size:16px; \">Literal Type</div>"); + outFile.println(" </div>"); + + + outFile.println(" <div style=\"width:48%; float:right; padding-top: 10px; \">"); + outFile.println("<div style=\"width: 110px; float: left; font-size:16px;\">Size</div>"); + outFile.println("<div style=\"width: 200px; float: left; text-align:left; font-size:16px; \">String Literal Type</div>"); + outFile.println(" </div>"); + + + outFile.println("<div style=\"height:35%; width:48%; margin:0 auto; background-color:white; float:left;\">"); + outFile.println("<iframe src=\"literalsBreakdown.html\" width=100% height=100% scrolling=auto></iframe>"); + outFile.println("</div>"); + makeLiteralsHtml("literalsBreakdown.html", nameToLitColl); + + outFile.println("<div style=\"height:35%; width:48%; margin:0 auto; background-color:white; float:right;\">"); + outFile.println("<iframe src=\"stringLiteralsBreakdown.html\" width=100% height=100% scrolling=auto></iframe>"); + outFile.println(" </div>"); + makeStringLiteralsHtml("stringLiteralsBreakdown.html", nameToLitColl); + + + if (GlobalInformation.fragmentToStories.size() > 1){ + outFile.println(" <div style=\"width:50%; float:left; padding-top: 10px;\">"); + outFile.println("<b>Breakdown by runAsync split points</b>"); + outFile.println(" </div>"); + + outFile.println(" <div style=\"width:100%; float:left; padding-top: 10px;\">"); + outFile.println("<div style=\"width: 110px; float: left; font-size:16px;\">Size</div>"); + outFile.println("<div style=\"width: 200px; float: left; text-align:left; font-size:16px; \">Fragment Name</div>"); + outFile.println(" </div>"); + + outFile.println("<div style=\"height:35%; width:100%; margin:0 auto; background-color:white; float:left;\">"); + outFile.println("<iframe src=\"fragmentsBreakdown.html\" width=100% height=100% scrolling=auto></iframe>"); + outFile.println("</div>"); + makeFragmentsHtml("fragmentsBreakdown.html"); + } + + outFile.println(" </body>"); + outFile.println("</html>"); + outFile.close(); + + } public static void makeLiteralsClassesTableHtmls(TreeMap<String, LiteralsCollection> nameToLitColl) throws IOException{ @@ -938,19 +1018,47 @@ } } - /** - * Makes html file for fragment classes. - * TODO(kprobst): update this once we have SOYC updated to supply enough information - * @throws IOException - */ - public static void makeFragmentClassesHtmls() throws IOException{ - - - for (Integer fragmentName : GlobalInformation.fragmentToStories.keySet()){ - HashSet<String> alreadyPrintedClasses = new HashSet<String>(); + public static void makePackageClassesHtmls() throws IOException{ + + for (String packageName : GlobalInformation.packageToClasses.keySet()){ - String outFileName = "fragment" + Integer.toString(fragmentName) + "Classes.html"; + String outFileName = packageName + "Classes.html"; + TreeMap<Float, String> sortedClasses = new TreeMap<Float, String>(Collections.reverseOrder()); + float maxSize = 0f; + //TODO(kprobst): not currently used, but will be for dependencies + int maxDepCount = 1; + + for (String className : GlobalInformation.packageToClasses.get(packageName)){ + + float curSize = 0f; + if (! GlobalInformation.classToPartialSize.containsKey(className)){ + System.err.println("*** NO PARTIAL SIZE FOUND FOR CLASS " + className + " *****"); + } + else{ + curSize = GlobalInformation.classToPartialSize.get(className); + } + + //TODO(kprobst): not currently used, but will be for dependencies + int depCount = 0; + if (GlobalInformation.classToWhatItDependsOn.containsKey(className)){ + depCount = GlobalInformation.classToWhatItDependsOn.get(className).size(); + } + + if (curSize != 0f){ + + sortedClasses.put(curSize, className); + if (curSize > maxSize){ + maxSize = curSize; + } + //TODO(kprobst): not currently used, but will be for dependencies + if (depCount > maxDepCount){ + maxDepCount = depCount; + } + } + } + + final PrintWriter outFile = new PrintWriter(outFileName); outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\""); @@ -958,64 +1066,250 @@ outFile.println("<html>"); outFile.println("<head>"); outFile.println("<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">"); - outFile.println("<title>Classes correlated with fragment " + Integer.toString(fragmentName) + " </title>"); + outFile.println("<link rel=\"stylesheet\" href=\"classLevel.css\" media=\"screen\">"); + outFile.println("<title>Classes in package \"" + packageName + "\"</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;/*cellspacing:poor IE support for this*/"); - outFile.println("border-collapse:separate;"); - outFile.println("}"); - outFile.println(".celldiv {"); - outFile.println("float:left;/*fix for buggy browsers*/"); - 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 correlated with fragment " + Integer.toString(fragmentName) + "</h2>"); + outFile.println("<h2>Classes in package \"" + packageName + "\"</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\">"); - - for (String storyName : GlobalInformation.fragmentToStories.get(fragmentName)){ - if (GlobalInformation.storiesToCorrClasses.containsKey(storyName)){ - for (String className : GlobalInformation.storiesToCorrClasses.get(storyName)){ - if (! alreadyPrintedClasses.contains(className)){ - //outFile.println("<div class=\"rowdiv\">"); - outFile.println("<div class=\"rowdiv\">" + className + "</div>"); - //outFile.println("</div>"); - alreadyPrintedClasses.add(className); - } - } + outFile.println("<div style=\"width:90%; height:80%; overflow-y:auto; overflow-x:auto; top: 90px; left:70px; position:absolute; background-color:white\""); + + + int yOffset = 0; + for (Float size : sortedClasses.keySet()){ + + String className = sortedClasses.get(size); + + //TODO(kprobst): switch out the commented/uncommented lines below when showing dependencies + float ratio = (size / maxSize) * 45; + //float ratio = (size / maxSize) * 85; + + if (ratio < 3){ + ratio = 3; } + + //TODO(kprobst): not currently used, but will be for dependencies + // get the dependency count + int depCount = 0; + if (GlobalInformation.classToWhatItDependsOn.containsKey(className)){ + depCount = GlobalInformation.classToWhatItDependsOn.get(className).size(); + } + float depRatio = ((float)depCount / (float)maxDepCount) * 45f; + if (depRatio < 3.0){ + depRatio = 3; + } + + outFile.println("<div class=\"box\" style=\"width:" + ratio + "%; top: " + yOffset + "px; left: 60px;\">"); + outFile.println("<div id=\"lb\">"); + outFile.println("<div id=\"rb\">"); + outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">"); + outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">"); + outFile.println("<div id=\"content\">"); + outFile.println("</div>"); + outFile.println("</div></div></div></div>"); + outFile.println("</div></div></div></div>"); + outFile.println("</div>"); + + + //TODO(kprobst): not currently used, but will be for dependencies + // place holder for mock-up of dependency display + outFile.println("<div class=\"box-right\" style=\"width:" + depRatio + "%; top: " + yOffset + "px; left: 50%\">"); + outFile.println("<div id=\"lb\">"); + outFile.println("<div id=\"rb\">"); + outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">"); + outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">"); + outFile.println("<div id=\"content\">"); + outFile.println("</div>"); + outFile.println("</div></div></div></div>"); + outFile.println("</div></div></div></div>"); + outFile.println("</div>"); + + int yOffsetText = yOffset+8; + outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText + "px; left:5px;\">%.1f</div>\n", size); + outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText + "px; left:70px;\">"+className+"</div>"); + //TODO(kprobst) make this a link + String drillDownFileName = className + "Deps.html"; + outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText + "px; left:50%;\"><a href=\"" + drillDownFileName + "\" target=\"_top\">Dependencies: " + depCount + "</a></div>"); + + yOffset = yOffset + 25; + } + outFile.println("</div>"); 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 + * @throws IOException + */ + public static 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 != 0)&&(!GlobalInformation.splitPointToLocation.containsKey(fragmentName))){ + + // get the stories from ALL the fragments + for (String storyName : GlobalInformation.fragmentToStories.get(fragmentName)){ + if ((!GlobalInformation.nameToLitColl.get("string").storyToLocations.containsKey(storyName))&&(GlobalInformation.storiesToCorrClassesAndMethods.containsKey(storyName))){ + for (String className : GlobalInformation.storiesToCorrClassesAndMethods.get(storyName)){ + sortedClassesAndMethodsAllOtherFragments.add(className); + } + } + } + } + +// else if ((fragmentName == 0)||(GlobalInformation.splitPointToLocation.containsKey(fragmentName))){ + else{ + String curSplitPointLocation; + + if (fragmentName == 0){ + curSplitPointLocation = "initialDownload"; + } + else{ + curSplitPointLocation = GlobalInformation.splitPointToLocation.get(fragmentName); + } + + String outFileName = "splitPoint" + curSplitPointLocation + "Classes.html"; + + final PrintWriter outFile = new PrintWriter(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;/*cellspacing:poor IE support for this*/"); + outFile.println("border-collapse:separate;"); + outFile.println("}"); + outFile.println(".celldiv {"); + outFile.println("float:left;/*fix for buggy browsers*/"); + 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.nameToLitColl.get("string").storyToLocations.containsKey(storyName))&&(GlobalInformation.storiesToCorrClassesAndMethods.containsKey(storyName))){ + for (String className : GlobalInformation.storiesToCorrClassesAndMethods.get(storyName)){ + sortedClassesAndMethods.add(className); + } + } + } + for (String classOrMethod : sortedClassesAndMethods){ + outFile.println("<div class=\"rowdiv\">" + classOrMethod + "</div>"); + } + + outFile.println("</div>"); + outFile.println("</body>"); + outFile.println("</html>"); + outFile.close(); + } + } + + + //finally, make the file for all the other fragments + String outFileName = "splitPointAllOtherFragmentsClasses.html"; + + final PrintWriter outFile = new PrintWriter(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 \"allOtherFragments\" </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;/*cellspacing:poor IE support for this*/"); + outFile.println("border-collapse:separate;"); + outFile.println("}"); + outFile.println(".celldiv {"); + outFile.println("float:left;/*fix for buggy browsers*/"); + 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 \"allOtherFragments\"</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\">"); + + for (String classOrMethod : sortedClassesAndMethodsAllOtherFragments){ + outFile.println("<div class=\"rowdiv\">" + classOrMethod + "</div>"); + } + + outFile.println("</div>"); + outFile.println("</body>"); + outFile.println("</html>"); + outFile.close(); + + + + } + public static void makeStringLiteralsClassesHtmls(TreeMap<String, LiteralsCollection> nameToLitColl) throws IOException{ @@ -1129,11 +1423,6 @@ } - - - - - public static void makeStringLiteralsClassesTableHtmls(TreeMap<String, LiteralsCollection> nameToLitColl) throws IOException{ @@ -1242,68 +1531,4 @@ outFile.close(); } } - - - - - public static void makeDependenciesTableHtmls() throws IOException{ - - for (String className : GlobalInformation.classToWhatItDependsOn.keySet()){ - - String outFileName = className + "Deps.html"; - final PrintWriter outFile = new PrintWriter(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 that \"" + className + "\" depends on</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("</style>"); - - outFile.println("<body>"); - outFile.println("<center>"); - outFile.println("<h2>Classes that \"" + className + "\" depends on</h2>"); - outFile.println("</center>"); - outFile.println("<hr>"); - - outFile.println("<center>"); - outFile.println("<table border=\"1\" width=\"80%\" style=\"font-size: 11pt;\" bgcolor=\"white\">"); - - for (String depClassName : GlobalInformation.classToWhatItDependsOn.get(className)){ - - outFile.println("<tr>"); - outFile.println("<td width=\"80%\">" + depClassName + "</td>"); - outFile.println("</tr>"); - - } - - outFile.println("</table>"); - outFile.println("<center>"); - - outFile.println("</div>"); - outFile.println("</body>"); - outFile.println("</html>"); - outFile.close(); - } - } - - - - - public static String escapeXml(String unescaped) { - String escaped = unescaped.replaceAll("\\&", "&"); - escaped = escaped.replaceAll("\\<", "<"); - escaped = escaped.replaceAll("\\>", ">"); - escaped = escaped.replaceAll("\\\"", """); - escaped = escaped.replaceAll("\\'", "'"); - return escaped; - } - }
diff --git a/tools/soyc-vis/src/com/google/gwt/soyc/SoycDashboard.java b/tools/soyc-vis/src/com/google/gwt/soyc/SoycDashboard.java index 87d660a..4c8d760 100644 --- a/tools/soyc-vis/src/com/google/gwt/soyc/SoycDashboard.java +++ b/tools/soyc-vis/src/com/google/gwt/soyc/SoycDashboard.java
@@ -45,56 +45,30 @@ String inFileName = args[0]; // to store literals data - final TreeMap<String, LiteralsCollection> nameToLitColl = new TreeMap<String, LiteralsCollection>(); - nameToLitColl.put("long",new LiteralsCollection("long")); - nameToLitColl.put("null",new LiteralsCollection("null")); - nameToLitColl.put("class",new LiteralsCollection("class")); - nameToLitColl.put("int",new LiteralsCollection("int")); - nameToLitColl.put("string",new LiteralsCollection("string")); - nameToLitColl.put("number",new LiteralsCollection("number")); - nameToLitColl.put("boolean",new LiteralsCollection("boolean")); - nameToLitColl.put("double",new LiteralsCollection("double")); - nameToLitColl.put("char",new LiteralsCollection("char")); - nameToLitColl.put("undefined",new LiteralsCollection("undefined")); - nameToLitColl.put("float",new LiteralsCollection("float")); + GlobalInformation.nameToLitColl.put("long",new LiteralsCollection("long")); + GlobalInformation.nameToLitColl.put("null",new LiteralsCollection("null")); + GlobalInformation.nameToLitColl.put("class",new LiteralsCollection("class")); + GlobalInformation.nameToLitColl.put("int",new LiteralsCollection("int")); + GlobalInformation.nameToLitColl.put("string",new LiteralsCollection("string")); + GlobalInformation.nameToLitColl.put("number",new LiteralsCollection("number")); + GlobalInformation.nameToLitColl.put("boolean",new LiteralsCollection("boolean")); + GlobalInformation.nameToLitColl.put("double",new LiteralsCollection("double")); + GlobalInformation.nameToLitColl.put("char",new LiteralsCollection("char")); + GlobalInformation.nameToLitColl.put("undefined",new LiteralsCollection("undefined")); + GlobalInformation.nameToLitColl.put("float",new LiteralsCollection("float")); // to store code data - final HashMap<String, CodeCollection> nameToCodeColl = new HashMap<String, CodeCollection>(); - nameToCodeColl.put("allOther", new CodeCollection("allOther")); - nameToCodeColl.put("widget", new CodeCollection("widget")); - nameToCodeColl.put("rpcUser", new CodeCollection("rpcUser")); - nameToCodeColl.put("rpcGen", new CodeCollection("rpcGen")); - nameToCodeColl.put("rpcGwt", new CodeCollection("rpcGwt")); - nameToCodeColl.put("gwtLang", new CodeCollection("long")); - nameToCodeColl.put("jre", new CodeCollection("jre")); + GlobalInformation.nameToCodeColl.put("allOther", new CodeCollection("allOther")); + GlobalInformation.nameToCodeColl.put("widget", new CodeCollection("widget")); + GlobalInformation.nameToCodeColl.put("rpcUser", new CodeCollection("rpcUser")); + GlobalInformation.nameToCodeColl.put("rpcGen", new CodeCollection("rpcGen")); + GlobalInformation.nameToCodeColl.put("rpcGwt", new CodeCollection("rpcGwt")); + GlobalInformation.nameToCodeColl.put("gwtLang", new CodeCollection("long")); + GlobalInformation.nameToCodeColl.put("jre", new CodeCollection("jre")); - // get the number of split points (so we know what code to ignore) - DefaultHandler fragmentCountHandler = scanXMLDocument(); - - // start parsing - SAXParserFactory factory = SAXParserFactory.newInstance(); - factory.setNamespaceAware(true); - try { - SAXParser saxParser = factory.newSAXParser(); - InputStream in = new FileInputStream(inFileName); - if (inFileName.endsWith(".gz")) { - in = new GZIPInputStream(in); - } - in = new BufferedInputStream(in); - saxParser.parse(in,fragmentCountHandler); - } catch (ParserConfigurationException e) { - throw new RuntimeException("Could not parse document. ", e); - } catch (SAXException e) { - throw new RuntimeException("Could not create SAX parser. ", e); - } catch (FileNotFoundException e) { - throw new RuntimeException("Could not open file. ", e); - } catch (IOException e) { - throw new RuntimeException("Could not open file. ", e); - } - GlobalInformation.numSplitPoints = (int)((float)(GlobalInformation.numFragments - 1) / 3f); // make the parser handler - DefaultHandler handler = parseXMLDocument(nameToLitColl, nameToCodeColl); + DefaultHandler handler = parseXMLDocument(GlobalInformation.nameToLitColl, GlobalInformation.nameToCodeColl); // start parsing @@ -119,17 +93,17 @@ } // add to "All Other Code" if none of the special categories apply - updateAllOtherCodeType(nameToCodeColl); + updateAllOtherCodeType(GlobalInformation.nameToCodeColl); // now we need to aggregate numbers GlobalInformation.computePackageSizes(); GlobalInformation.computePartialPackageSizes(); // clean up the RPC categories - foldInRPCHeuristic(nameToCodeColl); + foldInRPCHeuristic(GlobalInformation.nameToCodeColl); // generate all the html files - makeHTMLFiles(nameToLitColl, nameToCodeColl); + makeHTMLFiles(GlobalInformation.nameToLitColl, GlobalInformation.nameToCodeColl); System.out.println("Finished creating reports. To see the dashboard, open SoycDashboard-index.html in your browser."); } @@ -155,6 +129,7 @@ boolean specialCodeType = false; StringBuilder valueBuilder = new StringBuilder(); int ct = 0; + boolean fragmentInLoadOrder = false; /** * This method deals with the beginning of the XML element. @@ -171,7 +146,11 @@ valueBuilder.delete(0,valueBuilder.length()); - if ((strippedName.compareTo("package") == 0)&&(attributes.getValue("id") != null)){ + if (strippedName.compareTo("splitpoint") == 0){ + System.out.println("about to process splitpoint"); + parseSplitPoint(attributes); + } + else if ((strippedName.compareTo("package") == 0)&&(attributes.getValue("id") != null)){ curPackage = attributes.getValue("id"); if (curPackage.compareTo("") == 0){ @@ -221,12 +200,18 @@ // ignore all code that is not in the first load order curFragment = Integer.parseInt(attributes.getValue("fragment")); - if(!((curFragment == 0)||(curFragment == (GlobalInformation.numSplitPoints+1))||(curFragment == (GlobalInformation.numSplitPoints+2))|| - ((curFragment >= 2) && (curFragment <= GlobalInformation.numSplitPoints)))){ - curFragment = -1; + if((curFragment == 0)|| + (curFragment == (GlobalInformation.numSplitPoints+1))|| + (curFragment == (GlobalInformation.numSplitPoints+2))|| + ((curFragment >= 2) && (curFragment <= GlobalInformation.numSplitPoints))){ + fragmentInLoadOrder = true; + } + else{ + fragmentInLoadOrder = false; } } else{ + curFragment = -2; } } @@ -258,30 +243,16 @@ int numBytes = value.getBytes().length; - if ((curStoryRef != null)&&(curFragment != -1)){ + if (curStoryRef != null){ - if ((!GlobalInformation.storiesToLitType.containsKey(curStoryRef))&&(! GlobalInformation.storiesToCorrClasses.containsKey(curStoryRef))){ - GlobalInformation.nonAttributedStories.add(curStoryRef); - GlobalInformation.nonAttributedBytes += numBytes; - } - - GlobalInformation.cumSizeAllCode += numBytes; - - if (curFragment == 0){ - GlobalInformation.cumSizeInitialFragment += numBytes; - } - - // go through all the classes for this story + //add this size to the current fragment if (GlobalInformation.storiesToCorrClasses.containsKey(curStoryRef)){ - if ((GlobalInformation.storiesToLitType.containsKey(curStoryRef))&&(GlobalInformation.storiesToCorrClasses.get(curStoryRef).size() > 0)){ GlobalInformation.numBytesDoubleCounted += numBytes; } float partialSize = (float)numBytes / (float)GlobalInformation.storiesToCorrClasses.get(curStoryRef).size(); - - //add this size to the current fragment if (!GlobalInformation.fragmentToPartialSize.containsKey(curFragment)){ GlobalInformation.fragmentToPartialSize.put(curFragment, partialSize); } @@ -289,45 +260,55 @@ float newSize = GlobalInformation.fragmentToPartialSize.get(curFragment) + partialSize; GlobalInformation.fragmentToPartialSize.put(curFragment, newSize); } + + // now do different things depending on whether this fragment is in the load order or not + if (fragmentInLoadOrder == false){ + GlobalInformation.allOtherFragmentsPartialSize += numBytes; + } + else{ + GlobalInformation.cumSizeAllCode += numBytes; + + if ((!GlobalInformation.storiesToLitType.containsKey(curStoryRef))&& + (!GlobalInformation.storiesToCorrClasses.containsKey(curStoryRef))){ + GlobalInformation.nonAttributedStories.add(curStoryRef); + GlobalInformation.nonAttributedBytes += numBytes; + } - for (String className : GlobalInformation.storiesToCorrClasses.get(curStoryRef)){ - // get the corresponding package - if (GlobalInformation.classToPackage.containsKey(className)){ - String packageName = GlobalInformation.classToPackage.get(className); - - if (!GlobalInformation.packageToClasses.containsKey(packageName)){ - TreeSet<String> insertSet = new TreeSet<String>(); - insertSet.add(className); - GlobalInformation.packageToClasses.put(packageName, insertSet); - } - else{ - GlobalInformation.packageToClasses.get(packageName).add(className); - } - - if (GlobalInformation.classToSize.containsKey(className)){ - int newSize = GlobalInformation.classToSize.get(className) + numBytes; - GlobalInformation.classToSize.put(className, newSize); - } - else{ - GlobalInformation.classToSize.put(className, numBytes); - } - - if (GlobalInformation.classToPartialSize.containsKey(className)){ - float newSize = GlobalInformation.classToPartialSize.get(className) + partialSize; - GlobalInformation.classToPartialSize.put(className, newSize); - } - else{ - GlobalInformation.classToPartialSize.put(className, partialSize); + + // go through all the classes for this story + for (String className : GlobalInformation.storiesToCorrClasses.get(curStoryRef)){ + // get the corresponding package + if (GlobalInformation.classToPackage.containsKey(className)){ + String packageName = GlobalInformation.classToPackage.get(className); + + if (!GlobalInformation.packageToClasses.containsKey(packageName)){ + TreeSet<String> insertSet = new TreeSet<String>(); + insertSet.add(className); + GlobalInformation.packageToClasses.put(packageName, insertSet); + } + else{ + GlobalInformation.packageToClasses.get(packageName).add(className); + } + + if (GlobalInformation.classToSize.containsKey(className)){ + int newSize = GlobalInformation.classToSize.get(className) + numBytes; + GlobalInformation.classToSize.put(className, newSize); + } + else{ + GlobalInformation.classToSize.put(className, numBytes); + } + + if (GlobalInformation.classToPartialSize.containsKey(className)){ + float newSize = GlobalInformation.classToPartialSize.get(className) + partialSize; + GlobalInformation.classToPartialSize.put(className, newSize); + } + else{ + GlobalInformation.classToPartialSize.put(className, partialSize); + } } } } } - - -/* else{ - System.err.println("----- NO CORR CLASSES FOUND FOR STORY " + curStoryRef + " ---------"); - }*/ - updateLitTypes(nameToLitColl, value, numBytes); } } @@ -343,13 +324,10 @@ int iNumCounted = 0; for (String relLitType : curRelevantLitTypes){ - iNumCounted++; //then give string literals special treatment if (relLitType.compareTo("string") == 0){ - - // note that this will double-count (i.e., it will count a string twice if it's in the output twice), as it should. nameToLitColl.get("string").cumStringSize += numBytes; @@ -417,15 +395,11 @@ HashSet<String> insertSet = new HashSet<String>(); insertSet.add(mostAppropriateLocation); nameToLitColl.get(relLitType).literalToLocations.put(value,insertSet); - } } } - - else{ - // note that this will double-count (i.e., it will count a literal twice if it's in the output twice), as it should. nameToLitColl.get(relLitType).cumSize += numBytes; @@ -442,9 +416,6 @@ } } } - - //System.out.println("value: |" + value + "| in story |" + curStoryRef + "| was counted " + iNumCounted + " times."); - } /* @@ -519,6 +490,30 @@ } /* + * parses the split points + */ + private void parseSplitPoint(Attributes attributes){ + System.out.println("processing split point"); + if (attributes.getValue("id") != null){ + String curSplitPoint = attributes.getValue("id"); + System.out.println("\tcurSplitPoint is: " + curSplitPoint); + if (attributes.getValue("location") != null){ + String curSplitPointLocation = attributes.getValue("location"); + + curSplitPointLocation = curSplitPointLocation.replaceAll("\\(L.*",""); + + System.out.println("\tcurSplitPointLocation is: " + curSplitPointLocation); + GlobalInformation.splitPointToLocation.put(Integer.parseInt(curSplitPoint), curSplitPointLocation); + GlobalInformation.numSplitPoints++; + + System.out.println("adding split point and location: " + curSplitPoint + "-->" + curSplitPointLocation); + System.out.println("\t(Number of split points is now: " + GlobalInformation.numSplitPoints + ")"); + + } + } + } + + /* * parses the "story" portion of the XML file */ private void parseStory(Attributes attributes) { @@ -542,14 +537,26 @@ Attributes attributes) { if (attributes.getValue("idref") != null){ + + String corrClassOrMethod = attributes.getValue("idref"); + String corrClass = attributes.getValue("idref"); - - + if (corrClass.contains(":")){ corrClass = corrClass.replaceAll(":.*", ""); } - + if (GlobalInformation.classToPackage.containsKey(corrClass)){ //if we know about this class + + if (! GlobalInformation.storiesToCorrClassesAndMethods.containsKey(curStoryId)){ + HashSet<String> insertSet = new HashSet<String>(); + insertSet.add(corrClassOrMethod); + GlobalInformation.storiesToCorrClassesAndMethods.put(curStoryId, insertSet); + } + else{ + GlobalInformation.storiesToCorrClassesAndMethods.get(curStoryId).add(corrClassOrMethod); + } + if (! GlobalInformation.storiesToCorrClasses.containsKey(curStoryId)){ HashSet<String> insertSet = new HashSet<String>(); @@ -579,12 +586,10 @@ String overriddenClass = attributes.getValue("idref"); + //TODO(kprobst): fix this -- we either generalize to classes, or the numbers are messed up... if (overriddenClass.contains(":")){ overriddenClass = overriddenClass.replaceAll(":.*", ""); } - if (overriddenClass.contains("$")){ - overriddenClass = overriddenClass.replaceAll("\\$.*", ""); - } if (overriddenClass.compareTo("com.google.gwt.user.client.ui.UIObject") == 0){ nameToCodeColl.get("widget").classes.add(curClassId); @@ -630,7 +635,6 @@ /* * parses the "depends on" portion of the XML file */ - //TODO(kprobst): not currently used, but will be for dependencies private void parseDependsOn(final HashMap<String, CodeCollection> nameToCodeColl, Attributes attributes) { if (curFunctionId.compareTo("") == 0){ if (attributes.getValue("idref") != null){ @@ -658,79 +662,6 @@ return handler; } - - - - private static DefaultHandler scanXMLDocument() { - - DefaultHandler handler = new DefaultHandler() { - - - /** - * This method deals with the beginning of the XML element. - * It analyzes the XML node and adds its information to the relevant literal or code collection for later analysis. - * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) - */ - @Override - public void startElement(String nsUri, String strippedName, String tagName, Attributes attributes) { - - if (strippedName.compareTo("js") == 0){ - if (attributes.getValue("fragment") != null){ - GlobalInformation.numFragments++; - } - } - } - }; - - return handler; - } - - - /* - * assigns code to "all other code" if none of the special categories apply - */ - private static void updateAllOtherCodeType(final HashMap<String, CodeCollection> nameToCodeColl){ - //all classes not in any of the other categories - for (String className : GlobalInformation.classToPackage.keySet()){ - if ( (!nameToCodeColl.get("widget").classes.contains(className))&& - (!nameToCodeColl.get("rpcUser").classes.contains(className))&& - (!nameToCodeColl.get("rpcGwt").classes.contains(className))&& - (!nameToCodeColl.get("rpcGen").classes.contains(className))&& - (!nameToCodeColl.get("jre").classes.contains(className))&& - (!nameToCodeColl.get("gwtLang").classes.contains(className))){ - nameToCodeColl.get("allOther").classes.add(className); - } - } - } - - /* - * generates all the HTML files - */ - private static void makeHTMLFiles( - final TreeMap<String, LiteralsCollection> nameToLitColl, - final HashMap<String, CodeCollection> nameToCodeColl) { - - try { - MakeTopLevelHtmlForPerm.makePackageClassesHtmls(); - MakeTopLevelHtmlForPerm.makeCodeTypeClassesHtmls(nameToCodeColl); - MakeTopLevelHtmlForPerm.makeLiteralsClassesTableHtmls(nameToLitColl); - MakeTopLevelHtmlForPerm.makeStringLiteralsClassesTableHtmls(nameToLitColl); - MakeTopLevelHtmlForPerm.makeFragmentClassesHtmls(); - MakeTopLevelHtmlForPerm.makeDependenciesTableHtmls(); - - //make the shell last so we can display aggregate information here - MakeTopLevelHtmlForPerm.makeHTMLShell(nameToCodeColl, nameToLitColl); - - - - - - } catch (IOException e) { - throw new RuntimeException("Cannot open file. ", e); - } - } - - /* * cleans up the RPC code categories */ @@ -741,7 +672,7 @@ * application really is not using RPC */ - + if (nameToCodeColl.get("rpcGen").classes.size() == 0){ for (String className : nameToCodeColl.get("rpcUser").classes){ @@ -760,14 +691,61 @@ (! nameToCodeColl.get("gwtLang").classes.contains(className))){ nameToCodeColl.get("allOther").classes.add(className); } - + } nameToCodeColl.get("rpcGwt").classes.clear(); } - - } + } + + + /* + * generates all the HTML files + */ + private static void makeHTMLFiles( + final TreeMap<String, LiteralsCollection> nameToLitColl, + final HashMap<String, CodeCollection> nameToCodeColl) { + + try { + MakeTopLevelHtmlForPerm.makePackageClassesHtmls(); + MakeTopLevelHtmlForPerm.makeCodeTypeClassesHtmls(nameToCodeColl); + MakeTopLevelHtmlForPerm.makeLiteralsClassesTableHtmls(nameToLitColl); + MakeTopLevelHtmlForPerm.makeStringLiteralsClassesTableHtmls(nameToLitColl); + // MakeTopLevelHtmlForPerm.makeFragmentClassesHtmls(); + MakeTopLevelHtmlForPerm.makeSplitPointClassesHtmls(); + MakeTopLevelHtmlForPerm.makeDependenciesTableHtmls(); + + //make the shell last so we can display aggregate information here + MakeTopLevelHtmlForPerm.makeHTMLShell(nameToCodeColl, nameToLitColl); + + + + + + } catch (IOException e) { + throw new RuntimeException("Cannot open file. ", e); + } + } + + + /* + * assigns code to "all other code" if none of the special categories apply + */ + private static void updateAllOtherCodeType(final HashMap<String, CodeCollection> nameToCodeColl){ + //all classes not in any of the other categories + for (String className : GlobalInformation.classToPackage.keySet()){ + if ( (!nameToCodeColl.get("widget").classes.contains(className))&& + (!nameToCodeColl.get("rpcUser").classes.contains(className))&& + (!nameToCodeColl.get("rpcGwt").classes.contains(className))&& + (!nameToCodeColl.get("rpcGen").classes.contains(className))&& + (!nameToCodeColl.get("jre").classes.contains(className))&& + (!nameToCodeColl.get("gwtLang").classes.contains(className))){ + nameToCodeColl.get("allOther").classes.add(className); + } + } + } + /* * unescape the JS snippets - in the XML file they are XML encoded for correct display, but this