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

Unified Diff: petitparser/lib/src/debug/profile.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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 | « petitparser/lib/src/debug/continuation.dart ('k') | petitparser/lib/src/debug/progress.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: petitparser/lib/src/debug/profile.dart
diff --git a/petitparser/lib/src/debug/profile.dart b/petitparser/lib/src/debug/profile.dart
deleted file mode 100644
index 7c285567dd41f2ae4138f969d93883b68cfc59d8..0000000000000000000000000000000000000000
--- a/petitparser/lib/src/debug/profile.dart
+++ /dev/null
@@ -1,49 +0,0 @@
-part of debug;
-
-/**
- * Returns a transformed [parser] that when being used measures
- * the activation count and total time of each parser.
- *
- * For example, the snippet
- *
- * var parser = letter() & word().star();
- * profile(parser).parse('f1234567890');
- *
- * produces the following output:
- *
- * 1 2006 Instance of 'SequenceParser'
- * 1 697 Instance of 'PossessiveRepeatingParser'[0..*]
- * 11 406 Instance of 'CharacterParser'[letter or digit expected]
- * 1 947 Instance of 'CharacterParser'[letter expected]
- *
- * The first number refers to the number of activations of each parser, and
- * the second number is the microseconds spent in this parser and all its
- * children.
- */
-Parser profile(Parser root, [OutputHandler output = print]) {
- var count = new Map();
- var watch = new Map();
- var parsers = new List();
- return new ContinuationParser(transformParser(root, (parser) {
- parsers.add(parser);
- return new ContinuationParser(parser, (continuation, context) {
- count[parser]++;
- watch[parser].start();
- var result = continuation(context);
- watch[parser].stop();
- return result;
- });
- }), (continuation, context) {
- parsers.forEach((parser) {
- count[parser] = 0;
- watch[parser] = new Stopwatch();
- });
- var result = continuation(context);
- parsers.forEach((parser) {
- output('${count[parser]}\t'
- '${watch[parser].elapsedMicroseconds}\t'
- '${parser}');
- });
- return result;
- });
-}
« no previous file with comments | « petitparser/lib/src/debug/continuation.dart ('k') | petitparser/lib/src/debug/progress.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698