diff -r 4e79c3ae8a12 Lib/pstats.py --- a/Lib/pstats.py Wed Aug 21 01:34:18 2013 -0700 +++ b/Lib/pstats.py Wed Aug 21 10:59:11 2013 +0100 @@ -154,20 +154,22 @@ # list the tuple indices and directions for sorting, # along with some printable description sort_arg_dict_default = { - "calls" : (((1,-1), ), "call count"), - "ncalls" : (((1,-1), ), "call count"), - "cumtime" : (((3,-1), ), "cumulative time"), - "cumulative": (((3,-1), ), "cumulative time"), - "file" : (((4, 1), ), "file name"), - "filename" : (((4, 1), ), "file name"), - "line" : (((5, 1), ), "line number"), - "module" : (((4, 1), ), "file name"), - "name" : (((6, 1), ), "function name"), - "nfl" : (((6, 1),(4, 1),(5, 1),), "name/file/line"), - "pcalls" : (((0,-1), ), "primitive call count"), - "stdname" : (((7, 1), ), "standard name"), - "time" : (((2,-1), ), "internal time"), - "tottime" : (((2,-1), ), "internal time"), + "calls" : (((1,-1), ), "call count"), + "ncalls" : (((1,-1), ), "call count"), + "cumtime" : (((4,-1), ), "cumulative time"), + "cumulative" : (((4,-1), ), "cumulative time"), + "file" : (((6, 1), ), "file name"), + "filename" : (((6, 1), ), "file name"), + "line" : (((7, 1), ), "line number"), + "module" : (((6, 1), ), "file name"), + "name" : (((8, 1), ), "function name"), + "nfl" : (((8, 1),(6, 1),(7, 1),), "name/file/line"), + "pcalls" : (((0,-1), ), "primitive call count"), + "stdname" : (((9, 1), ), "standard name"), + "time" : (((2,-1), ), "internal time"), + "tottime" : (((2,-1), ), "internal time"), + "cumulativepercall": (((5,-1), ), "cumulative time per call"), + "totalpercall" : (((3,-1), ), "total time per call"), } def get_sort_arg_defs(self): @@ -211,7 +213,17 @@ stats_list = [] for func, (cc, nc, tt, ct, callers) in self.stats.items(): - stats_list.append((cc, nc, tt, ct) + func + + if nc == 0: + npc = 0 + else: + npc = float(tt)/nc + + if cc == 0: + cpc = 0 + else: + cpc = float(ct)/cc + + stats_list.append((cc, nc, tt, npc, ct, cpc) + func + (func_std_string(func), func)) stats_list.sort(key=cmp_to_key(TupleComp(sort_tuple).compare))