Revision: 5571
Author:   [email protected]
Date:     Thu Aug 22 08:11:25 2013 UTC
Log:      report sizes of js files during build
https://codereview.appspot.com/13111047

This modifies the <transform> ant task so that it reports the
sizes of its inputs and outputs. So when we capture ant build
output, we can pull out the js sizes and track it over time.

output looks like this:

[transform] input 1021 bytes from caja-iframe-build-version.js
[transform] input 781 bytes from createExports.js
[transform] input 66327 bytes from acorn.js
[transform] input 82047 bytes from escodegen.js
[transform] input 12080 bytes from estraverse.js
[transform] input 1145 bytes from exportsToSES.js
[transform] input 12400 bytes from mitigateGotchas.js
[transform] input 871 bytes from caja-iframe-done.js
[transform] building 8 files to ant-lib/com/google/caja/plugin/utility-frame.opt.js
[transform] output (javascript,minify) 93893 chars to utility-frame.opt.js
[transform] building 8 files to ant-lib/com/google/caja/plugin/utility-frame.js
[transform] output (concat) 176674 chars to utility-frame.js

R=kpreid2


http://code.google.com/p/google-caja/source/detail?r=5571

Modified:
 /trunk/src/com/google/caja/plugin/BuildServiceImplementation.java
 /trunk/src/com/google/caja/tools/TransformAntTask.java

=======================================
--- /trunk/src/com/google/caja/plugin/BuildServiceImplementation.java Thu Aug 8 19:09:03 2013 UTC +++ /trunk/src/com/google/caja/plugin/BuildServiceImplementation.java Thu Aug 22 08:11:25 2013 UTC
@@ -314,6 +314,10 @@
         }
         translatedCode = jsOut.toString();
       }
+
+      report("output (" + language + "," + rendererType + ") " +
+          translatedCode.length() + " chars to " +
+          output.getName());

       passed = FileIO.write(translatedCode, output, logger);
     }
@@ -351,10 +355,16 @@
       ok = false;
     }
     if (ok) {
+      report("output (concat) " + result.length() + " chars to "
+          + output.getName());
       ok = FileIO.write(result.toString(), output, logger);
     }
     return ok;
   }
+
+  private static void report(String s) {
+    System.out.println(s);
+  }

   // Loosely matches top-level strict declarations.
   //    False negative:  /* {} */ "use strict"
=======================================
--- /trunk/src/com/google/caja/tools/TransformAntTask.java Thu Aug 8 00:39:21 2013 UTC +++ /trunk/src/com/google/caja/tools/TransformAntTask.java Thu Aug 22 08:11:25 2013 UTC
@@ -74,12 +74,23 @@
  * @author [email protected]
  */
 public class TransformAntTask extends AbstractCajaAntTask {
+
+  private boolean reportedInputSizes = false;
+
   @Override
   protected boolean run(BuildService buildService, PrintWriter logger,
                         List<File> depends, List<File> inputs, File output,
                         Map<String, Object> options)
        throws BuildException {

+    if (!reportedInputSizes) {
+      for (File input : inputs) {
+        report("input " + input.length() + " bytes from " +
+            input.getName());
+      }
+      reportedInputSizes = true;
+    }
+
     if ("jslint".equals(options.get("language"))) {
       try {
return new Linter().build(jsLintInputs(), depends, options, output);
@@ -109,9 +120,15 @@
     if (closureOutput == null) {
       return false;
     }
+    report("output (closure) " + closureOutput.length() +
+        " chars to " + output.getName());
     FileIO.write(closureOutput, output, logger);
     return true;
   }
+
+  private static void report(String s) {
+    System.out.println(s);
+  }

   @Override
   Output makeOutput() {

--

--- You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to