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

Unified Diff: pkg/analysis_server/lib/src/services/completion/completion_manager.dart

Issue 796913004: enhance code completion tracking and measurement (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years 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/analysis_server/lib/src/services/completion/completion_manager.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/completion_manager.dart b/pkg/analysis_server/lib/src/services/completion/completion_manager.dart
index 4ffb40b4c50ec302c70c8684cd688897d261d405..c66da42a8885d3654a83fc6380bcfe79c3786218 100644
--- a/pkg/analysis_server/lib/src/services/completion/completion_manager.dart
+++ b/pkg/analysis_server/lib/src/services/completion/completion_manager.dart
@@ -75,8 +75,11 @@ abstract class CompletionManager {
* completion request sometime in the future. The default implementation
* of this method does nothing. Subclasses may override but should not
* count on this method being called before [computeSuggestions].
+ * Return a future that completes when the cache is computed with a bool
+ * indicating success.
*/
- void computeCache() {
+ Future<bool> computeCache() {
+ return new Future.value(true);
}
/**
@@ -109,13 +112,47 @@ class CompletionPerformance {
final Stopwatch _stopwatch = new Stopwatch();
final List<OperationPerformance> operations = <OperationPerformance>[];
+ Source source;
+ int offset;
+ String contents;
+ int notificationCount = -1;
+ int suggestionCount = -1;
+
CompletionPerformance() {
_stopwatch.start();
}
- void complete() {
+ int get elapsedInMilliseconds =>
+ operations.length > 0 ? operations.last.elapsed.inMilliseconds : 0;
+
+ String get snippet {
+ if (contents == null || offset < 0 || contents.length < offset) {
+ return '???';
+ }
+ int start = offset;
+ while (start > 0) {
+ String ch = contents[start - 1];
+ if (ch == '\r' || ch == '\n') {
+ break;
+ }
+ --start;
+ }
+ int end = offset;
+ while (end < contents.length) {
+ String ch = contents[end];
+ if (ch == '\r' || ch == '\n') {
+ break;
+ }
+ ++end;
+ }
+ String prefix = contents.substring(start, offset);
+ String suffix = contents.substring(offset, end);
+ return '$prefix^$suffix';
+ }
+
+ void complete([String tag = null]) {
_stopwatch.stop();
- _logDuration('total time', _stopwatch.elapsed);
+ _logDuration(tag != null ? tag : 'total time', _stopwatch.elapsed);
}
logElapseTime(String tag, [f() = null]) {

Powered by Google App Engine
This is Rietveld 408576698