Skip to content

Commit f646d19

Browse files
committed
Profile
1 parent 0cb6d84 commit f646d19

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,13 +1415,13 @@ def get_filename():
14151415
return f'profile-{time_str}.png'
14161416
```
14171417

1418-
#### Decorator for timing functions:
1418+
### Timing Decorators
1419+
#### Prints runtime of decorated function:
14191420
```python
14201421
from timeit import default_timer
14211422
from datetime import timedelta
14221423

14231424
def stopwatch(func):
1424-
"""Prints runtime of decorated function."""
14251425
def out(*args, **kwargs):
14261426
start = default_timer()
14271427
result = func(*args, **kwargs)
@@ -1431,13 +1431,12 @@ def stopwatch(func):
14311431
return out
14321432
```
14331433

1434-
#### Decorator for profiling functions:
1434+
#### Saves run call profile of the decorated function to file:
14351435
```python
14361436
from cProfile import Profile
14371437
from pstats import Stats
14381438

14391439
def profiler(func):
1440-
"""Saves run call profile of the decorated function to file."""
14411440
def out(*args, **kwargs):
14421441
profile = Profile()
14431442
result = profile.runcall(func, *args, **kwargs)
@@ -1451,10 +1450,9 @@ def profiler(func):
14511450
return out
14521451
```
14531452

1454-
#### Decorator for function tracing:
1453+
#### Prints arguments and output of a decorated function:
14551454
```python
14561455
def tracer(func):
1457-
"""Prints arguments and output of a decorated function."""
14581456
def out(*args, **kwargs):
14591457
result = func(*args, **kwargs)
14601458
arg_list = [repr(x) for x in args]

0 commit comments

Comments
 (0)