Commits

Anonymous committed f740f6f

Fixed bugs

Comments (0)

Files changed (1)

         stream = sys.stdout
     print >>stream, "File: %s" % filename
     print >>stream, "Function: %s at line %s" % (func_name, start_lineno)
-    template = '%6s %9s %12s %10s %8s %10s  %-s'
+    template = '%6s %9s %12s %10s %8s %11s  %-14s %-s'
     d = {}
     empty = ('', '', 0, 0, '')
     total_time = 0.0
     locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
 
     def grouped_number(d):
-        grouping = options.grouped_numbers
-        if d == '':
-            return d
+        grouping = True if options and options.grouped_numbers else False
+        if d == '' or d == 0:
+            return ""
         if type(d) == float:
             return locale.format("%0.1f", d, grouping=grouping)
         return locale.format("%d", d, grouping=grouping)
 
     lines_by_times = {}
-    header = template % ('Line #', 'Hits', 'Time', 'Per Hit', '% Time', "Block Sum",
-        'Line Contents')
+    header = template % ('Line #', 'Hits', 'Time', 'Per Hit', '% Time',
+                         "Block Sum", "Block Sum/Hit", 'Line Contents')
     print >>stream, ""
     print >>stream, header
     print >>stream, '=' * len(header)
     for lineno, line in zip(linenos, sublines):
         nhits, time, per_hit, percent, level_sum = d.get(lineno, empty)
-        t_sum = time
+        t_sum = 0
+        sum_per_hit = 0
         for s in level_sum:
             t_sum += s
         if time != '':
             if time > 1:
                 time = int(time)
 
+        if t_sum > 0:
+            t_sum += time
+
         if t_sum > 0 and not t_sum == '':
             t_sum = int(t_sum)
             if per_hit == 0:
-                per_hit = t_sum/nhits
+                sum_per_hit = t_sum/nhits
 
-        print >>stream, template % (lineno, nhits, grouped_number(time), '%s' % grouped_number(per_hit), '%5.1f' % percent, grouped_number(t_sum),
+        print >>stream, template % (lineno, grouped_number(nhits), grouped_number(time),
+                                    '%s' % grouped_number(per_hit),
+                                    grouped_number(percent),
+                                    grouped_number(t_sum),
+                                    grouped_number(sum_per_hit),
             line.rstrip('\n').rstrip('\r'))
     print >>stream, ""