3030 time = time . to_i
3131
3232 case type
33- when '<' :
34- # Can only return from inner or same depth level frame
33+ when '<' :
34+ # Can only return from inner or same depth level frame
3535 if not [ d , d - 1 ] . include? depth then
3636 print "Return from stack depth: " , d ,
3737 " to depth:" , depth , ", line " ,
4141 m = mstack . pop
4242 t = tstack . pop
4343
44- # Sanity check
44+ # Sanity check
4545 if not m == method then
4646 print "Method " , method , " not found at depth " ,
4747 depth , " line " , lines_read , "\n "
4848 return
49- end
49+ end
5050
51- # Total time for a method is the time to execute it minus the time to
52- # invoke all called methods
51+ # Total time for a method is the time to execute it minus the time to
52+ # invoke all called methods
5353 method_time = time - t
5454 results [ method ] = results . fetch ( method , 0 ) + method_time -
55- total_time_at_depth . fetch ( depth + 1 , 0 )
55+ total_time_at_depth . fetch ( depth + 1 , 0 )
5656
57- # Sanity check
57+ # Sanity check
5858 if method_time - total_time_at_depth . fetch ( depth + 1 , 0 ) < 0 then
59- print "Time required for method #{ method } (#{ method_time } ) less
59+ print "Time required for method #{ method } (#{ method_time } ) less
6060 than time for required for inner frame
6161 (#{ total_time_at_depth . fetch ( depth + 1 , 0 ) } )! " ,
62- "Line " , lines_read , "\n "
62+ "Line " , lines_read , "\n "
6363 return
6464 end
6565
66- # Total for a frame is the total time of its first level decendant
67- # plus the time required to execute all methods at the same depth
66+ # Total for a frame is the total time of its first level decendant
67+ # plus the time required to execute all methods at the same depth
6868 total_time_at_depth [ depth ] = method_time -
69- total_time_at_depth . fetch ( depth + 1 , 0 ) +
69+ total_time_at_depth . fetch ( depth + 1 , 0 ) +
7070 total_time_at_depth . fetch ( depth , 0 )
7171 # Inner stack frame time was used already at this depth,
72- # delete to avoid reusing
73- total_time_at_depth . delete ( depth + 1 )
72+ # delete to avoid reusing
73+ total_time_at_depth . delete ( depth + 1 )
7474
75- # Reset total time for depth 0 after it has been used
76- # since the statement above never runs at this depth
75+ # Reset total time for depth 0 after it has been used
76+ # since the statement above never runs at this depth
7777 if depth == 0 :
7878 total_time_at_depth . delete ( depth )
7979 end
80- when '>' :
81- # Can only go into an inner or same depth level frame
80+ when '>' :
81+ # Can only go into an inner or same depth level frame
8282 if not [ d , d + 1 ] . include? depth then
8383 print "Jump from stack depth: #{ d } to depth: #{ depth } ,
8484 line #{ lines_read } \n "
9494# Print results sorted
9595results . sort { |a , b | b [ 1 ] <=>a [ 1 ] } . each { |x |
9696 print "#{ x [ 0 ] } #{ x [ 1 ] } \n "
97- }
97+ }
0 commit comments