Skip to content

Commit 366f33f

Browse files
scheglovCommit Queue
authored andcommitted
Record LibraryAnalyzer and resolve / diagnostics performance.
Change-Id: I2d511a444df2a004ccce68343a89ce8b7d53aae0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406341 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent dc77d08 commit 366f33f

File tree

3 files changed

+41
-26
lines changed

3 files changed

+41
-26
lines changed

pkg/analyzer/lib/src/dart/analysis/driver.dart

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,16 +1392,19 @@ class AnalysisDriver {
13921392
libraryElement.typeSystem,
13931393
strictCasts: analysisOptions.strictCasts);
13941394

1395-
var results = LibraryAnalyzer(
1396-
analysisOptions,
1397-
declaredVariables,
1398-
libraryElement,
1399-
libraryContext.elementFactory.analysisSession.inheritanceManager,
1400-
library,
1401-
testingData: testingData,
1402-
typeSystemOperations: typeSystemOperations,
1403-
enableLintRuleTiming: _enableLintRuleTiming,
1404-
).analyze();
1395+
var results = performance.run('LibraryAnalyzer', (performance) {
1396+
return LibraryAnalyzer(
1397+
analysisOptions,
1398+
declaredVariables,
1399+
libraryElement,
1400+
libraryContext.elementFactory.analysisSession.inheritanceManager,
1401+
library,
1402+
performance: performance,
1403+
testingData: testingData,
1404+
typeSystemOperations: typeSystemOperations,
1405+
enableLintRuleTiming: _enableLintRuleTiming,
1406+
).analyze();
1407+
});
14051408

14061409
var isLibraryWithPriorityFile = _isLibraryWithPriorityFile(library);
14071410

@@ -2082,20 +2085,23 @@ class AnalysisDriver {
20822085
var typeSystemOperations = TypeSystemOperations(libraryElement.typeSystem,
20832086
strictCasts: analysisOptions.strictCasts);
20842087

2085-
var analysisResult = LibraryAnalyzer(
2086-
analysisOptions as AnalysisOptionsImpl,
2087-
declaredVariables,
2088-
libraryElement,
2089-
libraryContext.elementFactory.analysisSession.inheritanceManager,
2090-
library,
2091-
testingData: testingData,
2092-
typeSystemOperations: typeSystemOperations,
2093-
).analyzeForCompletion(
2094-
file: file,
2095-
offset: request.offset,
2096-
unitElement: unitElement,
2097-
performance: performance,
2098-
);
2088+
var analysisResult = performance.run('LibraryAnalyzer', (performance) {
2089+
return LibraryAnalyzer(
2090+
analysisOptions as AnalysisOptionsImpl,
2091+
declaredVariables,
2092+
libraryElement,
2093+
libraryContext.elementFactory.analysisSession.inheritanceManager,
2094+
library,
2095+
performance: OperationPerformanceImpl('<root>'),
2096+
testingData: testingData,
2097+
typeSystemOperations: typeSystemOperations,
2098+
).analyzeForCompletion(
2099+
file: file,
2100+
offset: request.offset,
2101+
unitElement: unitElement,
2102+
performance: performance,
2103+
);
2104+
});
20992105

21002106
return ResolvedForCompletionResultImpl(
21012107
analysisSession: currentSession,

pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class AnalysisForCompletionResult {
7272

7373
/// Analyzer of a single library.
7474
class LibraryAnalyzer {
75+
final OperationPerformanceImpl performance;
7576
final AnalysisOptionsImpl _analysisOptions;
7677
final DeclaredVariables _declaredVariables;
7778
final LibraryFileKind _library;
@@ -96,6 +97,7 @@ class LibraryAnalyzer {
9697
this._libraryElement,
9798
this._inheritance,
9899
this._library, {
100+
required this.performance,
99101
TestingData? testingData,
100102
required TypeSystemOperations typeSystemOperations,
101103
bool enableLintRuleTiming = false,
@@ -117,8 +119,13 @@ class LibraryAnalyzer {
117119

118120
/// Compute analysis results for all units of the library.
119121
List<UnitAnalysisResult> analyze() {
120-
_parseAndResolve();
121-
_computeDiagnostics();
122+
performance.run('parseAndResolve', (performance) {
123+
_parseAndResolve();
124+
});
125+
126+
performance.run('computeDiagnostics', (performance) {
127+
_computeDiagnostics();
128+
});
122129

123130
// Return full results.
124131
var results = <UnitAnalysisResult>[];

pkg/analyzer/lib/src/dart/micro/resolve_file.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ class FileResolver {
595595
libraryElement,
596596
analysisSession.inheritanceManager,
597597
libraryKind,
598+
performance: OperationPerformanceImpl('<root>'),
598599
typeSystemOperations: typeSystemOperations,
599600
);
600601
_clearFileSystemStateParsedCache();
@@ -670,6 +671,7 @@ class FileResolver {
670671
libraryElement,
671672
libraryContext!.elementFactory.analysisSession.inheritanceManager,
672673
libraryKind,
674+
performance: OperationPerformanceImpl('<root>'),
673675
typeSystemOperations: typeSystemOperations,
674676
);
675677

0 commit comments

Comments
 (0)