-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9724a7a
commit 81e80f1
Showing
1 changed file
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,34 @@ | ||
# python-profiling-helpers | ||
A small python package for commonly used profiling tools. | ||
# Profiling Helpers | ||
|
||
A small python package that wraps Python's own `cProfile` library to make it more user friendly. | ||
|
||
|
||
When developing Python programs, you'll sometimes have functions that take a long time to execute and | ||
you are really not sure why. Profiling helps to find and analyze these bottlenecks and guides you | ||
into fixing performance problems. Uses [snakeviz](https://jiffyclub.github.io/snakeviz/) for interactive visualizations. | ||
|
||
Install it with `pip install profiling-helpers`. | ||
|
||
There are two decorators, `time_it` and `profile_it`. Use them anywhere in your code, like this: | ||
|
||
```python | ||
from profiling_helpers import time_it, profile_it | ||
from time import sleep | ||
|
||
@time_it | ||
def my_slow_function(x): | ||
sleep(10) | ||
return x | ||
|
||
my_slow_function(42) # Prints: Function "my_slow_function" took 10.01061 s to run | ||
``` | ||
|
||
|
||
```python | ||
@profile_it("my/profile/save/dir", open_visualization=True) | ||
def my_slow_function(x): | ||
sleep(10) | ||
return x | ||
|
||
my_slow_function(42) # Opens snakeviz after this function is completed | ||
``` |