https://github.com/aviramha/capara
Python profiler written in Rust for Contextual profiling.
https://github.com/aviramha/capara
asyncio contextvars profiler pyo3 python rust
Last synced: 2 months ago
JSON representation
Python profiler written in Rust for Contextual profiling.
- Host: GitHub
- URL: https://github.com/aviramha/capara
- Owner: aviramha
- License: mit
- Created: 2020-10-26T20:06:46.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-11-16T20:05:03.000Z (over 4 years ago)
- Last Synced: 2025-03-25T12:22:25.671Z (3 months ago)
- Topics: asyncio, contextvars, profiler, pyo3, python, rust
- Language: Rust
- Homepage:
- Size: 43.9 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# capara
Context aware Python asyncio rust analyzercapara is a profiler written in Rust that uses `ContextVars` for storing the profile results.
The main goal is to be able to profile *certain* asyncio tasks, out of concurrently running ones.
It's written in Rust for performance and safety, and also because I like Rust and it's good FFI and soundness experience.Currently capara captures all calls, not aggregated data, and each function call has a duration of nanoseconds.
Some functions might have None duration in case the profiler stopped before the `stop` function was called.capara doesn't maintain order of call currently, but should be easily achieveable in next versions.
Currently supports Python 3.8-3.9. Support of Python3.7 is achievable by sending a PR to PyO3 (I am lazy at this moment to solve this)
## Warning
capara heavily relies on Python FFI and is in very early development. Use with caution.# Why should I use capara?
You should use capara if you want to profile certain tasks in your asyncio code.
Other profilers would show data of all functions that ran, even if in background or not as part of your task.# Usage
```py
from capara.profiler import Profilerprofiler = Profiler()
with profiler:
do_somethingprofiler.results
## will return all functions profiled, in a list of tuple, each tuple containing an entry - (file_name, func_name, duration)
## duration is in nanoseconds.
```# License
capara was written by Aviram Hassan , copyright 2020, licensed under MIT license.
See `LICENSE`