Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Unified Diff: pkg/analyzer/lib/src/dart/analysis/driver.dart

Issue 2883633002: Extract PerformanceLogger from AnalysisDriver. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/dart/analysis/driver.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 469822ed1ad55bf6f2e2c5d3c6c1b7c1e3844e1e..b7ef542e463caf81a0ee750bc627ec2a98ab283b 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -31,6 +31,7 @@ import 'package:analyzer/src/summary/format.dart';
import 'package:analyzer/src/summary/idl.dart';
import 'package:analyzer/src/summary/package_bundle_reader.dart';
import 'package:front_end/src/base/api_signature.dart';
+import 'package:front_end/src/base/performace_logger.dart';
import 'package:front_end/src/incremental/byte_store.dart';
import 'package:meta/meta.dart';
@@ -1803,82 +1804,6 @@ class ParseResult {
}
/**
- * This class is used to gather and print performance information.
- */
-class PerformanceLog {
- final StringSink sink;
- int _level = 0;
-
- PerformanceLog(this.sink);
-
- /**
- * Enter a new execution section, which starts at one point of code, runs
- * some time, and then ends at the other point of code.
- *
- * The client must call [PerformanceLogSection.exit] for every [enter].
- */
- PerformanceLogSection enter(String msg) {
- writeln('+++ $msg.');
- _level++;
- return new PerformanceLogSection(this, msg);
- }
-
- /**
- * Return the result of the function [f] invocation and log the elapsed time.
- *
- * Each invocation of [run] creates a new enclosed section in the log,
- * which begins with printing [msg], then any log output produced during
- * [f] invocation, and ends with printing [msg] with the elapsed time.
- */
- /*=T*/ run/*<T>*/(String msg, /*=T*/ f()) {
- Stopwatch timer = new Stopwatch()..start();
- try {
- writeln('+++ $msg.');
- _level++;
- return f();
- } finally {
- _level--;
- int ms = timer.elapsedMilliseconds;
- writeln('--- $msg in $ms ms.');
- }
- }
-
- /**
- * Write a new line into the log.
- */
- void writeln(String msg) {
- if (sink != null) {
- String indent = '\t' * _level;
- sink.writeln('$indent$msg');
- }
- }
-}
-
-/**
- * The performance measurement section for operations that start and end
- * at different place in code, so cannot be run using [PerformanceLog.run].
- *
- * The client must call [exit] for every [PerformanceLog.enter].
- */
-class PerformanceLogSection {
- final PerformanceLog _logger;
- final String _msg;
- final Stopwatch _timer = new Stopwatch()..start();
-
- PerformanceLogSection(this._logger, this._msg);
-
- /**
- * Stop the timer, log the time.
- */
- void exit() {
- _timer.stop();
- _logger._level--;
- int ms = _timer.elapsedMilliseconds;
- _logger.writeln('--- $_msg in $ms ms.');
- }
-}
-
-/**
* The result with the [CompilationUnitElement] of a single file.
*
* These results are self-consistent, i.e. all elements and types accessible

Powered by Google App Engine
This is Rietveld 408576698