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

Unified Diff: tools/lexer_generator/generator.py

Issue 158823002: Experimental parser: refactor TransitionKey to use Term (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 10 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 | « tools/lexer_generator/code_generator.py ('k') | tools/lexer_generator/regex_parser.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/generator.py
diff --git a/tools/lexer_generator/generator.py b/tools/lexer_generator/generator.py
index 6d6ea83c38ea61cd8195c6401b6f4801046f8df1..629402ccbdd173a0e49e869fb390d8548b7710b9 100644
--- a/tools/lexer_generator/generator.py
+++ b/tools/lexer_generator/generator.py
@@ -106,6 +106,21 @@ def lex(rule_processor, string):
for t in rule_processor.default_automata().dfa().lex(string + '\0'):
print t
+def start_profiling():
+ import cProfile
+ pr = cProfile.Profile()
+ pr.enable()
+ return pr
+
+def stop_profiling(pr):
+ import pstats, StringIO
+ pr.disable()
+ s = StringIO.StringIO()
+ sortby = 'cumulative'
+ ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
+ ps.print_stats()
+ print s.getvalue()
+
if __name__ == '__main__':
parser = argparse.ArgumentParser()
@@ -120,12 +135,16 @@ if __name__ == '__main__':
parser.add_argument('--no-inline', action='store_true')
parser.add_argument('--verbose', action='store_true')
parser.add_argument('--debug-code', action='store_true')
+ parser.add_argument('--profile', action='store_true')
parser.add_argument('--rule-html')
args = parser.parse_args()
minimize_default = not args.no_minimize_default
verbose = args.verbose
+ if args.profile:
+ profiler = start_profiling()
+
re_file = args.re
if verbose:
print "parsing %s" % re_file
@@ -178,3 +197,6 @@ if __name__ == '__main__':
if input_file:
with open(input_file, 'r') as f:
lex(rule_processor, f.read())
+
+ if args.profile:
+ stop_profiling(profiler)
« no previous file with comments | « tools/lexer_generator/code_generator.py ('k') | tools/lexer_generator/regex_parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698