Reviewers: kpreid2,

Description:
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

Please review this at https://codereview.appspot.com/13111047/

Affected files:
  M     src/com/google/caja/plugin/BuildServiceImplementation.java
  M     src/com/google/caja/tools/TransformAntTask.java


Index: src/com/google/caja/plugin/BuildServiceImplementation.java
===================================================================
--- src/com/google/caja/plugin/BuildServiceImplementation.java (revision 5570) +++ src/com/google/caja/plugin/BuildServiceImplementation.java (working copy)
@@ -315,6 +315,10 @@
         translatedCode = jsOut.toString();
       }

+      report("output (" + language + "," + rendererType + ") " +
+          translatedCode.length() + " chars to " +
+          output.getName());
+
       passed = FileIO.write(translatedCode, output, logger);
     }
     return passed;
@@ -351,11 +355,17 @@
       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"
   //    False positive:  /* "use strict" */
Index: src/com/google/caja/tools/TransformAntTask.java
===================================================================
--- src/com/google/caja/tools/TransformAntTask.java     (revision 5570)
+++ src/com/google/caja/tools/TransformAntTask.java     (working copy)
@@ -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,10 +120,16 @@
     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() {
     return new TranslateTaskOutput();


--

--- 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