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

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

Issue 2554573006: Add a benchmark for summary prelinking. (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 c446833d724f847fcbd957939b315848b6e65a22..4fa76ed5867abd8f575e1de9e67f7f5ebf9d64d4 100644
--- a/pkg/front_end/tool/perf.dart
+++ b/pkg/front_end/tool/perf.dart
@@ -20,6 +20,8 @@ import 'package:analyzer/src/generated/parser.dart';
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/prelink.dart';
import 'package:analyzer/src/summary/summarize_ast.dart';
import 'package:kernel/analyzer/loader.dart';
import 'package:kernel/kernel.dart';
@@ -81,6 +83,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++) unlinkedSummarizeFiles(files);
+ },
+ 'prelinked_summarize': () async {
+ Set<Source> files = scanReachableFiles(entryUri);
+ // TODO(sigmund): replace the warmup with instrumented snapshots.
+ for (int i = 0; i < 10; i++) prelinkedSummarizeFiles(files);
}
};
@@ -209,6 +216,52 @@ void unlinkedSummarizeFiles(Set<Source> files) {
parseTimer.elapsedMicroseconds);
}
+/// Produces prelinked summaries for every file in [files] and reports the time
+/// spent doing so.
+void prelinkedSummarizeFiles(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 = <Source, UnlinkedUnit>{};
+ for (var source in files) {
+ unlinkedSummaries[source] = unlinkedSummarize(source);
+ }
+ var prelinkTimer = new Stopwatch()..start();
+ for (var source in files) {
+ UnlinkedUnit getSummary(String uri) {
+ var resolvedUri = sources.resolveUri(source, uri);
+ var result = unlinkedSummaries[resolvedUri];
+ if (result == null) {
+ print('Warning: no summary found for: $uri');
+ }
+ return result;
+ }
+
+ UnlinkedPublicNamespace getImport(String uri) =>
+ getSummary(uri)?.publicNamespace;
+ String getDeclaredVariable(String s) => null;
+ prelink(
+ unlinkedSummaries[source], getSummary, getImport, getDeclaredVariable);
+ }
+ prelinkTimer.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);
+}
+
/// 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