| Index: pkg/compiler/lib/src/apiimpl.dart
|
| diff --git a/pkg/compiler/lib/src/apiimpl.dart b/pkg/compiler/lib/src/apiimpl.dart
|
| index 75ecf88a5b96519e5601d4ca99c95b05213288fc..8c48224f2300382f5e472d7247f80622d7bf735c 100644
|
| --- a/pkg/compiler/lib/src/apiimpl.dart
|
| +++ b/pkg/compiler/lib/src/apiimpl.dart
|
| @@ -19,7 +19,8 @@ import '../compiler_new.dart' as api;
|
| import 'commandline_options.dart';
|
| import 'common.dart';
|
| import 'common/tasks.dart' show
|
| - GenericTask;
|
| + GenericTask,
|
| + Measurer;
|
| import 'common/backend_api.dart' show
|
| Backend;
|
| import 'compiler.dart';
|
| @@ -411,14 +412,9 @@ class CompilerImpl extends Compiler {
|
| Future<elements.LibraryElement> analyzeUri(
|
| Uri uri,
|
| {bool skipLibraryWithPartOfTag: true}) {
|
| - List<Future> setupFutures = new List<Future>();
|
| - if (sdkLibraries == null) {
|
| - setupFutures.add(setupSdk());
|
| - }
|
| - if (packages == null) {
|
| - setupFutures.add(setupPackages(uri));
|
| - }
|
| - return Future.wait(setupFutures).then((_) => super.analyzeUri(uri));
|
| + return new Future(() => (sdkLibraries == null) ? setupSdk() : null)
|
| + .then((_) => packages == null ? setupPackages(uri) : null)
|
| + .then((_) => super.analyzeUri(uri));
|
| }
|
|
|
| Future setupPackages(Uri uri) {
|
| @@ -473,28 +469,47 @@ class CompilerImpl extends Compiler {
|
| }
|
|
|
| Future<bool> run(Uri uri) {
|
| - log('Using platform configuration at ${platformConfigUri}');
|
| -
|
| - return Future.wait([setupSdk(), setupPackages(uri)]).then((_) {
|
| - assert(sdkLibraries != null);
|
| - assert(packages != null);
|
| -
|
| - return super.run(uri).then((bool success) {
|
| - int cumulated = 0;
|
| + Duration setupDuration = measurer.wallClock.elapsed;
|
| + return selfTask.measureSubtask("CompilerImpl.run", () {
|
| + log('Using platform configuration at ${platformConfigUri}');
|
| +
|
| + return setupSdk().then((_) => setupPackages(uri)).then((_) {
|
| + assert(sdkLibraries != null);
|
| + assert(packages != null);
|
| + return super.run(uri);
|
| + }).then((bool success) {
|
| + StringBuffer timings = new StringBuffer();
|
| + timings.writeln("Timings:");
|
| + Duration totalDuration = measurer.wallClock.elapsed;
|
| + Duration asyncDuration = measurer.asyncWallClock.elapsed;
|
| + Duration cumulatedDuration = Duration.ZERO;
|
| for (final task in tasks) {
|
| - int elapsed = task.timing;
|
| - if (elapsed != 0) {
|
| - cumulated += elapsed;
|
| - log('${task.name} took ${elapsed}msec');
|
| + String running = task.isRunning ? "*" : "";
|
| + Duration duration = task.duration;
|
| + if (duration != Duration.ZERO) {
|
| + cumulatedDuration += duration;
|
| + timings.writeln(
|
| + ' $running${task.name} took'
|
| + ' ${duration.inMilliseconds}msec');
|
| for (String subtask in task.subtasks) {
|
| int subtime = task.getSubtaskTime(subtask);
|
| - log('${task.name} > $subtask took ${subtime}msec');
|
| + String running = task.getSubtaskIsRunning(subtask) ? "*" : "";
|
| + timings.writeln(
|
| + ' $running${task.name} > $subtask took ${subtime}msec');
|
| }
|
| }
|
| }
|
| - int total = totalCompileTime.elapsedMilliseconds;
|
| - log('Total compile-time ${total}msec;'
|
| - ' unaccounted ${total - cumulated}msec');
|
| + Duration unaccountedDuration =
|
| + totalDuration - cumulatedDuration - setupDuration - asyncDuration;
|
| + double percent = unaccountedDuration.inMilliseconds * 100
|
| + / totalDuration.inMilliseconds;
|
| + timings.write(
|
| + ' Total compile-time ${totalDuration.inMilliseconds}msec;'
|
| + ' setup ${setupDuration.inMilliseconds}msec;'
|
| + ' async ${asyncDuration.inMilliseconds}msec;'
|
| + ' unaccounted ${unaccountedDuration.inMilliseconds}msec'
|
| + ' (${percent.toStringAsFixed(2)}%)');
|
| + log("$timings");
|
| return success;
|
| });
|
| });
|
| @@ -543,7 +558,7 @@ class CompilerImpl extends Compiler {
|
|
|
| Future callUserProvider(Uri uri) {
|
| try {
|
| - return userProviderTask.measure(() => provider.readFromUri(uri));
|
| + return userProviderTask.measureIo(() => provider.readFromUri(uri));
|
| } catch (ex, s) {
|
| diagnoseCrashInUserCode('Uncaught exception in input provider', ex, s);
|
| rethrow;
|
| @@ -552,7 +567,7 @@ class CompilerImpl extends Compiler {
|
|
|
| Future<Packages> callUserPackagesDiscovery(Uri uri) {
|
| try {
|
| - return userPackagesDiscoveryTask.measure(
|
| + return userPackagesDiscoveryTask.measureIo(
|
| () => packagesDiscoveryProvider(uri));
|
| } catch (ex, s) {
|
| diagnoseCrashInUserCode('Uncaught exception in package discovery', ex, s);
|
|
|