Created
November 12, 2014 16:04
-
-
Save gorgogol/f0ca6fe8d66351d440d2 to your computer and use it in GitHub Desktop.
I put this script quickly together so I could follow the call stack in the profiler data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# textToTree | |
# This script takes a tab delimited file in the form: | |
# x.y.a ... | |
# x.y.b ... | |
# x.y.c ... | |
# x.y.d ... | |
# | |
# And produces a file in the form: | |
# x.y.a ... [y#a] | |
# x.y.b ... [y#a, y#b] | |
# x.y.c ... [y#a, y#b, y#c] | |
# x.y.d ... [y#d] | |
# | |
# I put this script quickly together so I could add the call stack to profiler output data. | |
from itertools import takewhile | |
import sys | |
is_deeper = ' '.__eq__ | |
def build_tree(): | |
#lines = iter(lines) | |
stack = [] | |
for line in sys.stdin: | |
methodName = line.split()[0].split('.')[-1] | |
className = line.split()[0].split('.')[-2] | |
indent = len(list(takewhile(is_deeper, line))) | |
stack[indent:] = [methodName.strip()] | |
print className+"#"+methodName+"\t"+"\t".join(line.split()[1:100]),"\t",stack | |
build_tree() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment