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

Unified Diff: tools/telemetry/third_party/coverage/lab/run_trace.py

Issue 1366913004: Add coverage Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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: tools/telemetry/third_party/coverage/lab/run_trace.py
diff --git a/tools/telemetry/third_party/coverage/lab/run_trace.py b/tools/telemetry/third_party/coverage/lab/run_trace.py
new file mode 100644
index 0000000000000000000000000000000000000000..ea0a6cb788abfbe4a07f873d3427f32c97c0e41c
--- /dev/null
+++ b/tools/telemetry/third_party/coverage/lab/run_trace.py
@@ -0,0 +1,35 @@
+# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
+# For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt
+
+"""Run a simple trace function on a file of Python code."""
+
+import os, sys
+
+nest = 0
+
+def trace(frame, event, arg):
+ global nest
+
+ if nest is None:
+ # This can happen when Python is shutting down.
+ return None
+
+ print "%s%s %s %d @%d" % (
+ " " * nest,
+ event,
+ os.path.basename(frame.f_code.co_filename),
+ frame.f_lineno,
+ frame.f_lasti,
+ )
+
+ if event == 'call':
+ nest += 1
+ if event == 'return':
+ nest -= 1
+
+ return trace
+
+the_program = sys.argv[1]
+
+sys.settrace(trace)
+execfile(the_program)
« no previous file with comments | « tools/telemetry/third_party/coverage/lab/platform_info.py ('k') | tools/telemetry/third_party/coverage/lab/show_platform.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698