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

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

Issue 3005683002: Add command line options to rank_stacks (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
« 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/compiler/tool/status_files/rank_stacks.dart
diff --git a/pkg/compiler/tool/status_files/rank_stacks.dart b/pkg/compiler/tool/status_files/rank_stacks.dart
index 31345e037b721d68eb82ca505a6f4a586e4aabe7..db40cbb48868b4a9e6cc160e0eaca0a8ed94a7dd 100644
--- a/pkg/compiler/tool/status_files/rank_stacks.dart
+++ b/pkg/compiler/tool/status_files/rank_stacks.dart
@@ -21,33 +21,59 @@ import 'dart:io';
import 'log_parser.dart';
import 'record.dart';
-// TODO(sra): Allow command-line setting of these parameters.
-const STACK_PRINT_LENGTH = 12;
-const HOW_MANY_STACKS = 30;
+const DEFAULT_STACK_PRINT_LENGTH = 12;
+const DEFAULT_HOW_MANY_STACKS = 20;
+const USAGE = """
+dart rank_stacks.dart [options] test-log
+
+--stacks=N, -sN: Print highest ranking N stacks (0 means all stacks).
+ Defaults to top ${DEFAULT_HOW_MANY_STACKS} stacks.
+
+--length=N, -lN: Print N frames of each stack.
+ Defaults to ${DEFAULT_STACK_PRINT_LENGTH} frames.
+""";
+
+int stackPrintLength = DEFAULT_STACK_PRINT_LENGTH;
+int howManyStacks = DEFAULT_HOW_MANY_STACKS;
+
+void die(String why) {
+ print(why);
+ print('Usage:\n${USAGE}');
+ exit(1);
+}
main(args) {
String text;
+ // Parse options.
for (String arg in args) {
- // Parse options.
+ Match m;
+ if ((m = new RegExp(r'(--stacks=|-s)(\d+)$').matchAsPrefix(arg)) != null) {
Siggi Cherem (dart-lang) 2017/08/26 02:09:00 consider using the `args` package?
sra1 2017/08/29 19:53:03 Done.
+ howManyStacks = int.parse(m.group(2));
+ continue;
+ }
+
+ if ((m = new RegExp(r'(--length=|-l)(\d+)$').matchAsPrefix(arg)) != null) {
+ stackPrintLength = int.parse(m.group(2));
+ continue;
+ }
+
+ if (arg.startsWith('-')) die("Unknown option '$arg'");
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);
+ die('File not found: $file.');
}
text = file.readAsStringSync();
} else {
- print("Extra file argument '$arg'.");
- exit(1);
+ die("Extra file argument '$arg'.");
}
}
if (text == null) {
- print('No input file.');
- exit(1);
+ die('No input file.');
}
var records = parse(text);
@@ -58,7 +84,7 @@ main(args) {
var leaves = trieLeaves(trie).toList();
leaves.sort((a, b) => b.length.compareTo(a.length));
- for (var leaf in leaves.take(HOW_MANY_STACKS)) {
+ for (var leaf in howManyStacks == 0 ? leaves : leaves.take(howManyStacks)) {
print('');
var examples = leaf.members.map((r) => r.fullReason).toSet().toList();
examples.sort();
@@ -71,7 +97,7 @@ main(args) {
print('${countAligned}${indentedExample}');
}
- for (var line in leaf.members.first.stack.take(STACK_PRINT_LENGTH)) {
+ for (var line in leaf.members.first.stack.take(stackPrintLength)) {
print(' $line');
}
}
« 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