Skip to content

Commit 2c0648d

Browse files
jensjohaCommit Queue
authored andcommitted
[analyzer cli] Don't ask for errors on the same file several times
``` $ out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart --silent --iterations=10 --gcs=5 --snapshot=pkg/analyzer_cli/bin/analyzer.aot.1 --snapshot=pkg/analyzer_cli/bin/analyzer.aot.2 --arguments="/tmp/extracted_compile_dart_compile/" Will now run 10 iterations with 2 snapshots. .............................. Comparing snapshot #1 (analyzer.aot.1) with snapshot #2 (analyzer.aot.2) msec task-clock:u: -7.7915% +/- 1.2399% (-851.98 +/- 135.58) (10934.74 -> 10082.76) page-faults:u: -1.7454% +/- 1.1131% (-2457.20 +/- 1566.98) (140777.80 -> 138320.60) cycles:u: -5.6010% +/- 1.2559% (-2318118149.50 +/- 519783195.96) (41387425609.80 -> 39069307460.30) instructions:u: -7.0130% +/- 0.5970% (-3636754009.20 +/- 309595118.25) (51857207312.90 -> 48220453303.70) branch-misses:u: -6.2869% +/- 4.5941% (-9795625.90 +/- 7158088.69) (155810738.90 -> 146015113.00) seconds time elapsed: -7.7884% +/- 1.2389% (-0.85 +/- 0.14) (10.94 -> 10.09) seconds user: -6.0176% +/- 1.4855% (-0.59 +/- 0.14) (9.75 -> 9.16) seconds sys: -22.3326% +/- 4.4197% (-0.27 +/- 0.05) (1.19 -> 0.92) Comparing GC: No change in combined time. ``` Change-Id: Ibb34829a42770c22567bc1399bcf7eaf26201e99 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449121 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
1 parent 1a218c0 commit 2c0648d

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

pkg/analyzer_cli/lib/src/analyzer_impl.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,16 @@ class AnalyzerImpl {
4747
/// specified the "--package-warnings" option.
4848
String? _selfPackageName;
4949

50+
final Set<String> gotErrorsFor;
51+
5052
AnalyzerImpl(
5153
this.analysisOptions,
5254
this.analysisDriver,
5355
this.libraryFile,
5456
this.options,
5557
this.stats,
5658
this.startTime,
59+
this.gotErrorsFor,
5760
);
5861

5962
void addCompilationUnitSource(
@@ -134,9 +137,11 @@ class AnalyzerImpl {
134137
/// Fills [errorsResults] using [files].
135138
Future<void> prepareErrors() async {
136139
for (var path in files) {
137-
var errorsResult = await analysisDriver.getErrors(path);
138-
if (errorsResult is ErrorsResult) {
139-
errorsResults.add(errorsResult);
140+
if (gotErrorsFor.add(path)) {
141+
var errorsResult = await analysisDriver.getErrors(path);
142+
if (errorsResult is ErrorsResult) {
143+
errorsResults.add(errorsResult);
144+
}
140145
}
141146
}
142147
}

pkg/analyzer_cli/lib/src/driver.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ class Driver implements CommandLineStarter {
262262

263263
// Analyze the libraries.
264264
var pathContext = resourceProvider.pathContext;
265+
final gotErrorsFor = <String>{};
265266
for (var path in filesToAnalyze) {
266267
if (file_paths.isAnalysisOptionsYaml(pathContext, path)) {
267268
var fileResult = analysisDriver.currentSession.getFile(path);
@@ -397,7 +398,12 @@ class Driver implements CommandLineStarter {
397398

398399
final kind = file.kind;
399400
if (kind is LibraryFileKind) {
400-
var status = await _runAnalyzer(file, options, formatter);
401+
var status = await _runAnalyzer(
402+
file,
403+
options,
404+
formatter,
405+
gotErrorsFor,
406+
);
401407
allResult = allResult.max(status);
402408
analyzedFiles.addAll(kind.files);
403409
} else if (kind is PartFileKind) {
@@ -468,6 +474,7 @@ class Driver implements CommandLineStarter {
468474
FileState file,
469475
CommandLineOptions options,
470476
ErrorFormatter formatter,
477+
Set<String> gotErrorsFor,
471478
) {
472479
var startTime = currentTimeMillis;
473480
final analysisDriver = this.analysisDriver!;
@@ -481,6 +488,7 @@ class Driver implements CommandLineStarter {
481488
options,
482489
stats,
483490
startTime,
491+
gotErrorsFor,
484492
);
485493
return analyzer.analyze(formatter);
486494
}

0 commit comments

Comments
 (0)