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

Unified Diff: pkg/compiler/tool/status_files/stacks.dart

Issue 2999753002: Collate stacks in test output (Closed)
Patch Set: Created 3 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/tool/status_files/stacks.dart
diff --git a/pkg/compiler/tool/status_files/stacks.dart b/pkg/compiler/tool/status_files/stacks.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a663e93514013c5b5dd71027dcd683e8f5104e04
--- /dev/null
+++ b/pkg/compiler/tool/status_files/stacks.dart
@@ -0,0 +1,99 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// $ dart stacks.dart LOG > STACK.txt
Siggi Cherem (dart-lang) 2017/08/09 18:09:06 consider renaming to include a verb that indicates
sra1 2017/08/09 20:15:13 Done.
+
+import 'dart:io';
+
+import 'log_parser.dart';
+
+const STACK_PRINT_LENGTH = 12;
+const HOW_MANY_STACKS = 30;
+
+main(args) {
+ String text;
+
+ for (String arg in args) {
+ // Parse options.
+
+ if (text == null) {
+ var uri = Uri.base.resolve(arg);
+ var file = new File.fromUri(uri);
+ if (!file.existsSync()) {
+ print('file not found: $file');
+ exit(1);
+ }
+ text = file.readAsStringSync();
+ } else {
+ print('Extra file argument "$arg"');
+ exit(1);
+ }
+ }
+
+ if (text == null) {
+ print('No input file');
+ exit(1);
+ }
+
+ var records = parse(text);
+ var trie = new TrieNode(null);
+ for (var record in records) {
+ enter(record, 0, trie);
+ }
+
+ var leaves = trieLeaves(trie).toList();
+ leaves.sort((a, b) => b.length.compareTo(a.length));
+ for (var leaf in leaves.take(HOW_MANY_STACKS)) {
+ print('');
+ var examples = leaf.members.map((r) => r.fullReason).toSet();
+ print('${leaf.length} of:');
+ for (var example in examples) {
+ example = '\t' + example.replaceAll('\n', '\n\t');
+ print(' .${example}');
+ }
+
+ for (var line in leaf.members.first.stack.take(STACK_PRINT_LENGTH)) {
+ print(' $line');
+ }
+ }
+}
+
+class TrieNode {
+ final int depth;
+ final String key;
+ final map = {};
Siggi Cherem (dart-lang) 2017/08/09 18:08:02 Map<String, TrieNode> ?
sra1 2017/08/09 20:15:13 Done.
+ final List<Record> members = <Record>[];
+
+ int get length => members.length;
+
+ TrieNode(this.key, [this.depth = 0]);
+
+ String toString() => 'TrieNode(#$length)';
+}
+
+void enter(Record record, int depth, TrieNode root) {
+ root.members.add(record);
+ if (depth >= record.stack.length) return;
+ var key = record.stack[depth];
+ var node = root.map[key] ??= new TrieNode(key, depth + 1);
+ enter(record, depth + 1, node);
+}
+
+void printTrie(TrieNode node) {
+ var indent = ' ' * node.depth;
+ print('${indent} ${node.length} ${node.key}');
+ for (var key in node.map.keys) {
+ printTrie(node.map[key]);
+ }
+}
+
+trieLeaves(node) sync* {
+ if (node.map.isEmpty) {
+ yield node;
+ } else {
+ for (var v in node.map.values) {
+ yield* trieLeaves(v);
+ }
+ }
+}
« pkg/compiler/tool/status_files/log_parser.dart ('K') | « pkg/compiler/tool/status_files/record.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698