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

Side by Side Diff: pkg/analyzer/lib/src/generated/engine.dart

Issue 844683003: Report incremental/full analysis performance via instrumentation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/instrumentation/instrumentation.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine; 8 library engine;
9 9
10 import "dart:math" as math; 10 import "dart:math" as math;
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 */ 914 */
915 static int _PRIORITY_ORDER_SIZE_DELTA = 4; 915 static int _PRIORITY_ORDER_SIZE_DELTA = 4;
916 916
917 /** 917 /**
918 * A flag indicating whether trace output should be produced as analysis tasks are performed. Used 918 * A flag indicating whether trace output should be produced as analysis tasks are performed. Used
919 * for debugging. 919 * for debugging.
920 */ 920 */
921 static bool _TRACE_PERFORM_TASK = false; 921 static bool _TRACE_PERFORM_TASK = false;
922 922
923 /** 923 /**
924 * The next context identifier.
925 */
926 static int _NEXT_ID = 0;
927
928 /**
929 * The unique identifier of this context.
930 */
931 final int _id = _NEXT_ID++;
932
933 /**
924 * The set of analysis options controlling the behavior of this context. 934 * The set of analysis options controlling the behavior of this context.
925 */ 935 */
926 AnalysisOptionsImpl _options = new AnalysisOptionsImpl(); 936 AnalysisOptionsImpl _options = new AnalysisOptionsImpl();
927 937
928 /** 938 /**
929 * A flag indicating whether errors related to sources in the SDK should be ge nerated and 939 * A flag indicating whether errors related to sources in the SDK should be ge nerated and
930 * reported. 940 * reported.
931 */ 941 */
932 bool _generateSdkErrors = true; 942 bool _generateSdkErrors = true;
933 943
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 * [cacheLock] before accessing this field. 1019 * [cacheLock] before accessing this field.
1010 */ 1020 */
1011 IncrementalAnalysisCache _incrementalAnalysisCache; 1021 IncrementalAnalysisCache _incrementalAnalysisCache;
1012 1022
1013 /** 1023 /**
1014 * The object used to manage the list of sources that need to be analyzed. 1024 * The object used to manage the list of sources that need to be analyzed.
1015 */ 1025 */
1016 WorkManager _workManager = new WorkManager(); 1026 WorkManager _workManager = new WorkManager();
1017 1027
1018 /** 1028 /**
1029 * The [Stopwatch] of the current "perform tasks cycle".
1030 */
1031 Stopwatch _performAnalysisTaskStopwatch;
1032
1033 /**
1019 * The controller for sending [SourcesChangedEvent]s. 1034 * The controller for sending [SourcesChangedEvent]s.
1020 */ 1035 */
1021 StreamController<SourcesChangedEvent> _onSourcesChangedController; 1036 StreamController<SourcesChangedEvent> _onSourcesChangedController;
1022 1037
1023 /** 1038 /**
1024 * The listeners that are to be notified when various analysis results are pro duced in this 1039 * The listeners that are to be notified when various analysis results are pro duced in this
1025 * context. 1040 * context.
1026 */ 1041 */
1027 List<AnalysisListener> _listeners = new List<AnalysisListener>(); 1042 List<AnalysisListener> _listeners = new List<AnalysisListener>();
1028 1043
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 print("----------------------------------------"); 2183 print("----------------------------------------");
2169 } 2184 }
2170 int getStart = JavaSystem.currentTimeMillis(); 2185 int getStart = JavaSystem.currentTimeMillis();
2171 AnalysisTask task = nextAnalysisTask; 2186 AnalysisTask task = nextAnalysisTask;
2172 int getEnd = JavaSystem.currentTimeMillis(); 2187 int getEnd = JavaSystem.currentTimeMillis();
2173 if (task == null && _validateCacheConsistency()) { 2188 if (task == null && _validateCacheConsistency()) {
2174 task = nextAnalysisTask; 2189 task = nextAnalysisTask;
2175 } 2190 }
2176 if (task == null) { 2191 if (task == null) {
2177 _validateLastIncrementalResolutionResult(); 2192 _validateLastIncrementalResolutionResult();
2193 if (_performAnalysisTaskStopwatch != null) {
2194 AnalysisEngine.instance.instrumentationService.logPerformance(
2195 AnalysisPerformanceKind.FULL,
2196 _performAnalysisTaskStopwatch,
2197 'context_id=$_id');
2198 _performAnalysisTaskStopwatch = null;
2199 }
2178 return new AnalysisResult( 2200 return new AnalysisResult(
2179 _getChangeNotices(true), 2201 _getChangeNotices(true),
2180 getEnd - getStart, 2202 getEnd - getStart,
2181 null, 2203 null,
2182 -1); 2204 -1);
2183 } 2205 }
2206 if (_performAnalysisTaskStopwatch == null) {
2207 _performAnalysisTaskStopwatch = new Stopwatch()..start();
2208 }
2184 String taskDescription = task.toString(); 2209 String taskDescription = task.toString();
2185 _notifyAboutToPerformTask(taskDescription); 2210 _notifyAboutToPerformTask(taskDescription);
2186 if (_TRACE_PERFORM_TASK) { 2211 if (_TRACE_PERFORM_TASK) {
2187 print(taskDescription); 2212 print(taskDescription);
2188 } 2213 }
2189 int performStart = JavaSystem.currentTimeMillis(); 2214 int performStart = JavaSystem.currentTimeMillis();
2190 try { 2215 try {
2191 task.perform(_resultRecorder); 2216 task.perform(_resultRecorder);
2192 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) { 2217 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) {
2193 AnalysisEngine.instance.logger.logInformation( 2218 AnalysisEngine.instance.logger.logInformation(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2228 if (incrementalResolutionValidation_lastUnitSource == null || 2253 if (incrementalResolutionValidation_lastUnitSource == null ||
2229 incrementalResolutionValidation_lastLibrarySource == null || 2254 incrementalResolutionValidation_lastLibrarySource == null ||
2230 incrementalResolutionValidation_lastUnit == null) { 2255 incrementalResolutionValidation_lastUnit == null) {
2231 return; 2256 return;
2232 } 2257 }
2233 CompilationUnit fullUnit = getResolvedCompilationUnit2( 2258 CompilationUnit fullUnit = getResolvedCompilationUnit2(
2234 incrementalResolutionValidation_lastUnitSource, 2259 incrementalResolutionValidation_lastUnitSource,
2235 incrementalResolutionValidation_lastLibrarySource); 2260 incrementalResolutionValidation_lastLibrarySource);
2236 if (fullUnit != null) { 2261 if (fullUnit != null) {
2237 try { 2262 try {
2238 assertSameResolution(incrementalResolutionValidation_lastUnit, fullUnit) ; 2263 assertSameResolution(
2264 incrementalResolutionValidation_lastUnit,
2265 fullUnit);
2239 } on IncrementalResolutionMismatch catch (mismatch, stack) { 2266 } on IncrementalResolutionMismatch catch (mismatch, stack) {
2240 String failure = mismatch.message; 2267 String failure = mismatch.message;
2241 String message = 'Incremental resolution mismatch:\n$failure\nat\n$stack '; 2268 String message =
2269 'Incremental resolution mismatch:\n$failure\nat\n$stack';
2242 AnalysisEngine.instance.logger.logError(message); 2270 AnalysisEngine.instance.logger.logError(message);
2243 } 2271 }
2244 } 2272 }
2245 incrementalResolutionValidation_lastUnitSource = null; 2273 incrementalResolutionValidation_lastUnitSource = null;
2246 incrementalResolutionValidation_lastLibrarySource = null; 2274 incrementalResolutionValidation_lastLibrarySource = null;
2247 incrementalResolutionValidation_lastUnit = null; 2275 incrementalResolutionValidation_lastUnit = null;
2248 } 2276 }
2249 2277
2250 @override 2278 @override
2251 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { 2279 void recordLibraryElements(Map<Source, LibraryElement> elementMap) {
(...skipping 2724 matching lines...) Expand 10 before | Expand all | Expand 10 after
4976 return false; 5004 return false;
4977 } 5005 }
4978 // prepare the existing unit 5006 // prepare the existing unit
4979 Source librarySource = librarySources[0]; 5007 Source librarySource = librarySources[0];
4980 CompilationUnit oldUnit = 5008 CompilationUnit oldUnit =
4981 getResolvedCompilationUnit2(unitSource, librarySource); 5009 getResolvedCompilationUnit2(unitSource, librarySource);
4982 if (oldUnit == null) { 5010 if (oldUnit == null) {
4983 return false; 5011 return false;
4984 } 5012 }
4985 // do resolution 5013 // do resolution
5014 Stopwatch perfCounter = new Stopwatch()..start();
4986 PoorMansIncrementalResolver resolver = new PoorMansIncrementalResolver( 5015 PoorMansIncrementalResolver resolver = new PoorMansIncrementalResolver(
4987 typeProvider, 5016 typeProvider,
4988 unitSource, 5017 unitSource,
4989 dartEntry, 5018 dartEntry,
4990 analysisOptions.incrementalApi); 5019 analysisOptions.incrementalApi);
4991 bool success = resolver.resolve(oldUnit, newCode); 5020 bool success = resolver.resolve(oldUnit, newCode);
5021 AnalysisEngine.instance.instrumentationService.logPerformance(
5022 AnalysisPerformanceKind.INCREMENTAL,
5023 perfCounter,
5024 'success=$success,context_id=$_id,code_length=${newCode.length}');
4992 if (!success) { 5025 if (!success) {
4993 return false; 5026 return false;
4994 } 5027 }
4995 // if validation, remember the result, but throw it away 5028 // if validation, remember the result, but throw it away
4996 if (analysisOptions.incrementalValidation) { 5029 if (analysisOptions.incrementalValidation) {
4997 incrementalResolutionValidation_lastUnitSource = oldUnit.element.source; 5030 incrementalResolutionValidation_lastUnitSource = oldUnit.element.source;
4998 incrementalResolutionValidation_lastLibrarySource = oldUnit.element.librar y.source; 5031 incrementalResolutionValidation_lastLibrarySource =
5032 oldUnit.element.library.source;
4999 incrementalResolutionValidation_lastUnit = oldUnit; 5033 incrementalResolutionValidation_lastUnit = oldUnit;
5000 return false; 5034 return false;
5001 } 5035 }
5002 // prepare notice 5036 // prepare notice
5003 ChangeNoticeImpl notice = _getNotice(unitSource); 5037 ChangeNoticeImpl notice = _getNotice(unitSource);
5004 notice.compilationUnit = oldUnit; 5038 notice.compilationUnit = oldUnit;
5005 // apply updated errors 5039 // apply updated errors
5006 { 5040 {
5007 LineInfo lineInfo = getLineInfo(unitSource); 5041 LineInfo lineInfo = getLineInfo(unitSource);
5008 notice.setErrors(dartEntry.allErrors, lineInfo); 5042 notice.setErrors(dartEntry.allErrors, lineInfo);
(...skipping 7152 matching lines...) Expand 10 before | Expand all | Expand 10 after
12161 if (element.id == _id) { 12195 if (element.id == _id) {
12162 result = element; 12196 result = element;
12163 throw new _ElementByIdFinderException(); 12197 throw new _ElementByIdFinderException();
12164 } 12198 }
12165 super.visitElement(element); 12199 super.visitElement(element);
12166 } 12200 }
12167 } 12201 }
12168 12202
12169 class _ElementByIdFinderException { 12203 class _ElementByIdFinderException {
12170 } 12204 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/instrumentation/instrumentation.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698