OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 trydart.poi; | 5 library trydart.poi; |
6 | 6 |
7 import 'dart:async' show | 7 import 'dart:async' show |
8 Completer, | 8 Completer, |
9 Future; | 9 Future; |
10 | 10 |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 } | 351 } |
352 } | 352 } |
353 return null; | 353 return null; |
354 } | 354 } |
355 | 355 |
356 Future<Element> runPoi( | 356 Future<Element> runPoi( |
357 Uri script, | 357 Uri script, |
358 int position, | 358 int position, |
359 api.CompilerInputProvider inputProvider, | 359 api.CompilerInputProvider inputProvider, |
360 api.DiagnosticHandler handler) { | 360 api.DiagnosticHandler handler) { |
| 361 Stopwatch sw = new Stopwatch()..start(); |
361 Uri libraryRoot = Uri.base.resolve('sdk/'); | 362 Uri libraryRoot = Uri.base.resolve('sdk/'); |
362 Uri packageRoot = Uri.base.resolveUri( | 363 Uri packageRoot = Uri.base.resolveUri( |
363 new Uri.file('${io.Platform.packageRoot}/')); | 364 new Uri.file('${io.Platform.packageRoot}/')); |
364 | 365 |
365 var options = [ | 366 var options = [ |
366 '--analyze-main', | 367 '--analyze-main', |
367 '--analyze-only', | 368 '--analyze-only', |
368 '--no-source-maps', | 369 '--no-source-maps', |
369 '--verbose', | 370 '--verbose', |
370 '--categories=Client,Server', | 371 '--categories=Client,Server', |
(...skipping 12 matching lines...) Expand all Loading... |
383 diagnosticHandler: handler, | 384 diagnosticHandler: handler, |
384 inputProvider: inputProvider, | 385 inputProvider: inputProvider, |
385 options: options, | 386 options: options, |
386 cachedCompiler: cachedCompiler, | 387 cachedCompiler: cachedCompiler, |
387 libraryRoot: libraryRoot, | 388 libraryRoot: libraryRoot, |
388 packageRoot: packageRoot, | 389 packageRoot: packageRoot, |
389 packagesAreImmutable: true, | 390 packagesAreImmutable: true, |
390 reuseLibrary: reuseLibrary).then((Compiler newCompiler) { | 391 reuseLibrary: reuseLibrary).then((Compiler newCompiler) { |
391 var filter = new ScriptOnlyFilter(script); | 392 var filter = new ScriptOnlyFilter(script); |
392 newCompiler.enqueuerFilter = filter; | 393 newCompiler.enqueuerFilter = filter; |
393 return runPoiInternal(newCompiler, updater, position); | 394 return runPoiInternal(newCompiler, sw, updater, position); |
394 }); | 395 }); |
395 } | 396 } |
396 | 397 |
397 Future<Element> runPoiInternal( | 398 Future<Element> runPoiInternal( |
398 Compiler newCompiler, | 399 Compiler newCompiler, |
| 400 Stopwatch sw, |
399 LibraryUpdater updater, | 401 LibraryUpdater updater, |
400 int position) { | 402 int position) { |
401 | 403 bool isFullCompile = cachedCompiler != newCompiler; |
402 cachedCompiler = newCompiler; | 404 cachedCompiler = newCompiler; |
403 if (poiTask == null || poiTask.compiler != cachedCompiler) { | 405 if (poiTask == null || poiTask.compiler != cachedCompiler) { |
404 poiTask = new PoiTask(cachedCompiler); | 406 poiTask = new PoiTask(cachedCompiler); |
405 cachedCompiler.tasks.add(poiTask); | 407 cachedCompiler.tasks.add(poiTask); |
406 } | 408 } |
407 | 409 |
| 410 if (!isFullCompile) { |
| 411 printFormattedTime( |
| 412 'Analyzing changes and updating elements took', sw.elapsedMicroseconds); |
| 413 } |
| 414 sw.reset(); |
| 415 |
408 Future<bool> compilation = cachedCompiler.run(updater.uri); | 416 Future<bool> compilation = cachedCompiler.run(updater.uri); |
409 | 417 |
410 return compilation.then((success) { | 418 return compilation.then((success) { |
| 419 printVerbose('Compiler queue processed in ${sw.elapsedMicroseconds}us'); |
411 if (isVerbose) { | 420 if (isVerbose) { |
412 for (final task in cachedCompiler.tasks) { | 421 for (final task in cachedCompiler.tasks) { |
413 int time = task.timingMicroseconds; | 422 int time = task.timingMicroseconds; |
414 if (time != 0) { | 423 if (time != 0) { |
415 printFormattedTime('${task.name} took', time); | 424 printFormattedTime('${task.name} took', time); |
416 } | 425 } |
417 } | 426 } |
418 } | 427 } |
419 | 428 |
420 if (poiCount != null) poiCount++; | 429 if (poiCount != null) poiCount++; |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 | 746 |
738 modelx.ImportScope importScope(modelx.LibraryElementX element) { | 747 modelx.ImportScope importScope(modelx.LibraryElementX element) { |
739 return element.importScope; | 748 return element.importScope; |
740 } | 749 } |
741 | 750 |
742 class PoiTask extends CompilerTask { | 751 class PoiTask extends CompilerTask { |
743 PoiTask(Compiler compiler) : super(compiler); | 752 PoiTask(Compiler compiler) : super(compiler); |
744 | 753 |
745 String get name => 'POI'; | 754 String get name => 'POI'; |
746 } | 755 } |
OLD | NEW |