A simple time, ram & vram python profiler.
Project description
A simple time and memory Python profiler
Usage
1. As a context manager
from tmprofile import Profile
with Profile(name, ...) as profiler:
f(...) # some intensive code
# profile is automatically saved as a json file.
# display elapsed time, RAM & VRAM consumption evolution
profiler.print()
profiler.plot()
2. As a decorator
from tmprofile import profile
@profile()
f(...) # some intensive code
# profile is automatically saved as a json file.
Parameters
name (str)
: Name of the profiler. Will be used to name the saved file. Required for context manager. For decorator, will use fonction'name if no name is provided.verbose (bool)
: If True, will print logged values at the end of profiling (i.e. on exit as a context manager, on function's return as a decorator). Defaults to False.gpu_idx (int)
: Which gpu's VRAM consumption has to be monitored. Default to0
.time_delta (float)
: Time to wait (in second) between two RAM / VRAM consumption logging. Defaults to0.2
.output_dir (str | Path)
: Where to write the logged values (as json). Defaults to.profile
.filename (str | Path, optional)
: Name of the saved json file. If no name is given, will used the profiler name (seename
above).
Disclaimer
The core of this code (asynchronous RAM/VRAM logging) is taken from Thomas Rouch's code here.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tmprofile-0.0.1.tar.gz
(6.4 kB
view hashes)
Built Distribution
Close
Hashes for tmprofile-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 485652b5e404d68e6c6f1380a378aba0aeb81b568ba9492c4781f1a097a6a449 |
|
MD5 | 571a20bd8c16cb9c44eebcd332024ea2 |
|
BLAKE2b-256 | 744a78a7aa251c2eb68762ba6b2390f3e6b89c1c4498cb9550be71e1ece53c72 |