| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dump_info; | 5 library dump_info; |
| 6 | 6 |
| 7 import 'elements/elements.dart'; | 7 import 'elements/elements.dart'; |
| 8 import 'elements/visitor.dart'; | 8 import 'elements/visitor.dart'; |
| 9 import 'dart:convert' show HtmlEscape; | 9 import 'dart:convert' show HtmlEscape; |
| 10 import 'dart2jslib.dart' show | 10 import 'dart2jslib.dart' show |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 class ProgramInfo { | 186 class ProgramInfo { |
| 187 /// A list of all the libraries in the program to show information about. | 187 /// A list of all the libraries in the program to show information about. |
| 188 final List<InfoNode> libraries; | 188 final List<InfoNode> libraries; |
| 189 | 189 |
| 190 /// The size of the whole program in bytes. | 190 /// The size of the whole program in bytes. |
| 191 final int size; | 191 final int size; |
| 192 | 192 |
| 193 /// The time the compilation took place. | 193 /// The time the compilation took place. |
| 194 final DateTime compilationMoment; | 194 final DateTime compilationMoment; |
| 195 | 195 |
| 196 /// The time the compilation took to complite. | 196 /// The time the compilation took to complete. |
| 197 final int compilationDuration; | 197 final Duration compilationDuration; |
| 198 | 198 |
| 199 /// The version of dart2js used to compile the program. | 199 /// The version of dart2js used to compile the program. |
| 200 final String dart2jsVersion; | 200 final String dart2jsVersion; |
| 201 | 201 |
| 202 ProgramInfo({this.libraries, | 202 ProgramInfo({this.libraries, |
| 203 this.size, | 203 this.size, |
| 204 this.compilationMoment, | 204 this.compilationMoment, |
| 205 this.compilationDuration, | 205 this.compilationDuration, |
| 206 this.dart2jsVersion}); | 206 this.dart2jsVersion}); |
| 207 } | 207 } |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 } | 429 } |
| 430 return l1.getLibraryName().compareTo(l2.getLibraryName()); | 430 return l1.getLibraryName().compareTo(l2.getLibraryName()); |
| 431 }); | 431 }); |
| 432 | 432 |
| 433 List<InfoNode> libraryInfos = new List<InfoNode>(); | 433 List<InfoNode> libraryInfos = new List<InfoNode>(); |
| 434 libraryInfos.addAll(sortedLibraries | 434 libraryInfos.addAll(sortedLibraries |
| 435 .map((library) => infoDumpVisitor.visit(library)) | 435 .map((library) => infoDumpVisitor.visit(library)) |
| 436 .where((info) => info != null)); | 436 .where((info) => info != null)); |
| 437 | 437 |
| 438 return new ProgramInfo( | 438 return new ProgramInfo( |
| 439 compilationDuration: compiler.totalCompileTime.elapsedTicks, | 439 compilationDuration: compiler.totalCompileTime.elapsed, |
| 440 // TODO (sigurdm): Also count the size of deferred code | 440 // TODO (sigurdm): Also count the size of deferred code |
| 441 size: compiler.assembledCode.length, | 441 size: compiler.assembledCode.length, |
| 442 libraries: libraryInfos, | 442 libraries: libraryInfos, |
| 443 compilationMoment: new DateTime.now(), | 443 compilationMoment: new DateTime.now(), |
| 444 dart2jsVersion: compiler.hasBuildId ? compiler.buildId : null); | 444 dart2jsVersion: compiler.hasBuildId ? compiler.buildId : null); |
| 445 } | 445 } |
| 446 | 446 |
| 447 void dumpInfoHtml(ProgramInfo info, StringSink buffer) { | 447 void dumpInfoHtml(ProgramInfo info, StringSink buffer) { |
| 448 int totalSize = info.size; | 448 int totalSize = info.size; |
| 449 | 449 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 461 span.modifiers {font-weight:bold;} | 461 span.modifiers {font-weight:bold;} |
| 462 span.name {font-weight:bold; font-family: monospace;} | 462 span.name {font-weight:bold; font-family: monospace;} |
| 463 span.type {font-family: monospace; color:blue;} | 463 span.type {font-family: monospace; color:blue;} |
| 464 </style> | 464 </style> |
| 465 </head> | 465 </head> |
| 466 <body> | 466 <body> |
| 467 <h1>Dart2js compilation information</h1>"""); | 467 <h1>Dart2js compilation information</h1>"""); |
| 468 buffer.writeln(h2('Compilation took place: ' | 468 buffer.writeln(h2('Compilation took place: ' |
| 469 '${info.compilationMoment}')); | 469 '${info.compilationMoment}')); |
| 470 buffer.writeln(h2('Compilation took: ' | 470 buffer.writeln(h2('Compilation took: ' |
| 471 '${info.compilationDuration/1000000} seconds')); | 471 '${info.compilationDuration.inSeconds} seconds')); |
| 472 buffer.writeln(h2('Output size: ${info.size} bytes')); | 472 buffer.writeln(h2('Output size: ${info.size} bytes')); |
| 473 if (info.dart2jsVersion != null) { | 473 if (info.dart2jsVersion != null) { |
| 474 buffer.writeln(h2('Dart2js version: ${info.dart2jsVersion}')); | 474 buffer.writeln(h2('Dart2js version: ${info.dart2jsVersion}')); |
| 475 } | 475 } |
| 476 | 476 |
| 477 info.libraries.forEach((InfoNode node) { | 477 info.libraries.forEach((InfoNode node) { |
| 478 node.emitHtml(info, buffer); | 478 node.emitHtml(info, buffer); |
| 479 }); | 479 }); |
| 480 | 480 |
| 481 | 481 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 492 var container = containers[i]; | 492 var container = containers[i]; |
| 493 container.addEventListener('click', | 493 container.addEventListener('click', |
| 494 toggler(container.nextElementSibling), false); | 494 toggler(container.nextElementSibling), false); |
| 495 container.nextElementSibling.hidden = true; | 495 container.nextElementSibling.hidden = true; |
| 496 }; | 496 }; |
| 497 </script> | 497 </script> |
| 498 </body> | 498 </body> |
| 499 </html>"""); | 499 </html>"""); |
| 500 } | 500 } |
| 501 } | 501 } |
| OLD | NEW |