[issue9285] A decorator for cProfile and profile modules
Giampaolo Rodola'
report at bugs.python.org
Sat Jul 17 16:01:14 CEST 2010
New submission from Giampaolo Rodola' <g.rodola at gmail.com>:
A patch including tests is in attachment.
Example usage:
>>> from cProfile import profile
>>>
>>> @profile
... def factorial(n):
... n = abs(int(n))
... if n < 1:
... n = 1
... x = 1
... for i in range(1, n+1):
... x = i * x
... return x
...
>>>
>>> factorial(5)
Thu Jul 15 20:58:21 2010 /tmp/tmpIDejr5
4 function calls in 0.000 CPU seconds
Ordered by: internal time, call count
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 profiler.py:120(factorial)
1 0.000 0.000 0.000 0.000 {range}
1 0.000 0.000 0.000 0.000 {abs}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
120
>>>
Before including doc changes I'd like to hear whether this is actually desirable or not.
----------
assignee: collinwinter
components: Benchmarks, Library (Lib)
files: profile.patch
keywords: needs review, patch, patch
messages: 110555
nosy: collinwinter, giampaolo.rodola, pitrou
priority: normal
severity: normal
status: open
title: A decorator for cProfile and profile modules
versions: Python 3.2
Added file: http://bugs.python.org/file18039/profile.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9285>
_______________________________________
More information about the Python-bugs-list
mailing list