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

Unified Diff: pkg/front_end/tool/perf.dart

Issue 2556723005: Add a perf test for generating linked summaries. (Closed)
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/tool/perf.dart
diff --git a/pkg/front_end/tool/perf.dart b/pkg/front_end/tool/perf.dart
index 4fa76ed5867abd8f575e1de9e67f7f5ebf9d64d4..be4f3d1f7fc035e1829a62872188ebb56bd78793 100644
--- a/pkg/front_end/tool/perf.dart
+++ b/pkg/front_end/tool/perf.dart
@@ -21,6 +21,7 @@ import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/source_io.dart';
import 'package:analyzer/src/summary/format.dart';
import 'package:analyzer/src/summary/idl.dart';
+import 'package:analyzer/src/summary/link.dart';
import 'package:analyzer/src/summary/prelink.dart';
import 'package:analyzer/src/summary/summarize_ast.dart';
import 'package:kernel/analyzer/loader.dart';
@@ -88,6 +89,11 @@ main(List<String> args) async {
Set<Source> files = scanReachableFiles(entryUri);
// TODO(sigmund): replace the warmup with instrumented snapshots.
for (int i = 0; i < 10; i++) prelinkedSummarizeFiles(files);
+ },
+ 'linked_summarize': () async {
+ Set<Source> files = scanReachableFiles(entryUri);
+ // TODO(sigmund): replace the warmup with instrumented snapshots.
+ for (int i = 0; i < 10; i++) linkedSummarizeFiles(files);
}
};
@@ -262,6 +268,61 @@ void prelinkedSummarizeFiles(Set<Source> files) {
report('prelink', prelinkTimer.elapsedMicroseconds);
}
+/// Produces linked summaries for every file in [files] and reports the time
+/// spent doing so.
+void linkedSummarizeFiles(Set<Source> files) {
+ // The code below will record again how many chars are scanned and how long it
+ // takes to scan them, even though we already did so in [scanReachableFiles].
+ // Recording and reporting this twice is unnecessary, but we do so for now to
+ // validate that the results are consistent.
+ scanTimer = new Stopwatch();
+ var old = scanTotalChars;
+ scanTotalChars = 0;
+ parseTimer = new Stopwatch();
+ unlinkedSummarizeTimer = new Stopwatch();
+ var unlinkedSummaries = <String, UnlinkedUnit>{};
+ for (var source in files) {
+ unlinkedSummaries[source.uri.toString()] = unlinkedSummarize(source);
+ }
+ var prelinkTimer = new Stopwatch()..start();
+ Set<String> libraryUris =
+ files.map((source) => source.uri.toString()).toSet();
+ UnlinkedUnit getUnit(String uri) {
+ var result = unlinkedSummaries[uri];
+ if (result == null) {
+ print('Warning: no summary found for: $uri');
+ }
+ return result;
+ }
+
+ String getDeclaredVariable(String s) => null;
+ var prelinkedLibraries =
+ setupForLink(libraryUris, getUnit, getDeclaredVariable);
Siggi Cherem (dart-lang) 2016/12/07 23:21:29 is there a difference between prelink and setupFor
Paul Berry 2016/12/07 23:54:40 Good point. PTAL.
+ prelinkTimer.stop();
+ var linkTimer = new Stopwatch()..start();
+ LinkedLibrary getDependency(String uri) {
+ // getDependency should never be called because all dependencies are present
+ // in [prelinkedLibraries].
+ print('Warning: getDependency called for: $uri');
+ return null;
+ }
+
+ bool strong = true;
+ relink(prelinkedLibraries, getDependency, getUnit, strong);
+ linkTimer.stop();
+
+ if (old != scanTotalChars) print('input size changed? ${old} chars');
+ report("scan", scanTimer.elapsedMicroseconds);
+ report("parse", parseTimer.elapsedMicroseconds);
+ report('unlinked summarize', unlinkedSummarizeTimer.elapsedMicroseconds);
+ report(
+ 'unlinked summarize + parse',
+ unlinkedSummarizeTimer.elapsedMicroseconds +
+ parseTimer.elapsedMicroseconds);
+ report('prelink', prelinkTimer.elapsedMicroseconds);
+ report('link', linkTimer.elapsedMicroseconds);
+}
+
/// Add to [files] all sources reachable from [start].
void collectSources(Source start, Set<Source> files) {
if (!files.add(start)) return;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698