Commits

Robert Kern committed 8c6d5af

ENH: Display per-hit time for each line.
BUG: Spelling typo.

Comments (0)

Files changed (1)

     print >>stream, 'Function: %s at line %s' % (func_name, start_lineno)
     all_lines = linecache.getlines(filename)
     sublines = inspect.getblock(all_lines[start_lineno-1:])
-    template = '%6s %9s %12s %8s  %-s'
+    template = '%6s %9s %12s %8s %8s  %-s'
     d = {}
     total_time = 0.0
     for lineno, nhits, time in timings:
         total_time += time
     print >>stream, 'Total time: %g s' % (total_time * unit)
     for lineno, nhits, time in timings:
-        d[lineno] = (nhits, time, '%5.1f' % (100*time / total_time))
+        d[lineno] = (nhits, time, '%6g' % (float(time) / nhits), '%5.1f' % (100*time / total_time))
     linenos = range(start_lineno, start_lineno + len(sublines))
-    empty = ('', '', '')
-    header = template % ('Line #', 'Hits', 'Time', '% Time', 'Line Contents')
+    empty = ('', '', '', '')
+    header = template % ('Line #', 'Hits', 'Time', 'Per Hit', '% Time', 'Line Contents')
     print >>stream, ''
     print >>stream, header
     print >>stream, '=' * len(header)
     for lineno, line in zip(linenos, sublines):
-        nhits, time, percent = d.get(lineno, empty)
-        print >>stream, template % (lineno, nhits, time, percent, line.rstrip('\n').rstrip('\r'))
+        nhits, time, per_hit, percent = d.get(lineno, empty)
+        print >>stream, template % (lineno, nhits, time, per_hit, percent, line.rstrip('\n').rstrip('\r'))
     print >>stream, ''
 
 def show_text(stats, unit, stream=None):
             funcs.append(eval(name, global_ns, local_ns))
         except Exception, e:
             raise UsageError('Could not find function %r.\n%s: %s' % (name, 
-                e.__class__.__name, e))
+                e.__class__.__name__, e))
 
     profile = LineProfiler(*funcs)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.