A wrapper for some existing python profilers
Project description
coinstac python profiler
Profile your python code (includes code running using coinstac-simulator). This primarily uses pyinstrument profiler, but can also be extended to include other python profilers
Prerequisites
Python 3.6+
Other packages listed in Requirements.txt
Usage
NOTE: The code currently implements profiling based on pyinstrument profiler. Other profilier (such as cprofile) can be included based on requirements.
First way:
Use the following line above the method definition which needs to be profiled.
from coinstac_pyprofiler import custom_profiler as cprof
@cprof.profile(type="pyinstrument", output_file_prefix=output_file_prefix)
Decorator class to profile any method. Note: 'output_file_prefix' should include its (absolute) directory path
Second way:
Create object of Profile class in custom_profiler.py and use start() and stop() methods to control profiling.
from coinstac_pyprofiler import custom_profiler as cprof
@cprof.profile(type="pyinstrument", output_file_prefix=output_file_prefix)
profile = cprof.Profile(type='pyinstrument', output_file_prefix=<your_dir_path>/<some_file_prefix>")
profile.start()
<your code to profile>
profile.stop()
profile.persist_log()
Merging multiple profile output files
Merges the json profiler output files generated using pyinstrument profiling and saves merged output.
Use-case:
For a computation in coinstac-simulator, some computation has many iterations and every iteration of python call generates a separate profile json output file. All such json files can be merged separately for each client/remote using this call.
Example
An example usage is included in tests/examples/profiler_usage.py which demonstrates the usage of the above mentioned profiling methods and also provides examples to merge multiple profile output files.
Happy profiling!!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for coinstac_pyprofiler-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a75d6911ed4d4c1903c75886c14228e6b531a2cb4e05f24c1e90485a6cb0b158 |
|
MD5 | 53d9b181b4197c2c1970df8f1980ce2a |
|
BLAKE2b-256 | fa3a5480427ca4cdd5478bb5945ab9b90682e251d12247220b3a7844aa5b3c5f |
Hashes for coinstac_pyprofiler-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bbc6e916f238aa10351055b9781a438a64f67c4a5d678d699c45d8cccbf68f3 |
|
MD5 | 657648229fbdb3e3b7e23bef32de68d7 |
|
BLAKE2b-256 | 05f896f4d27e4327e6cf4276bec5dd68285f6df6a40ee40a743fe4fffff17d62 |