Convert profiler log output to an outline. Let's say we have a simple profiler that logs a line to a file with the time when each method is entered or exited. For example, if main() calls foo() then the output is:
t1, main, enter
t2, foo1, enter
t3, foo1, exit
t4, foo2, enter
t5, foo2, exit
t6, main, exitFor above logs, output should be printed as. Note there is a tab after main.
main (t6 - t1)
foo1 (t3 - t2)
foo2 (t5 - t4)Follow up:
What if same function is getting called over and again as in recursion?
t1, main, enter
t2, foo, enter
t3, foo, enter
t4, foo, exit
t5, foo, exit
t6, main, exitFor above logs, output should be printed as. Note there is a tab after main.
main (t6 - t1)
foo (t4 - t3)
foo (t5 - t2)