https://github.com/pykit3/k3stopwatch
StopWatch - library for adding timers and tags in your code for performance monitoring
https://github.com/pykit3/k3stopwatch
python stopwatch
Last synced: 4 months ago
JSON representation
StopWatch - library for adding timers and tags in your code for performance monitoring
- Host: GitHub
- URL: https://github.com/pykit3/k3stopwatch
- Owner: pykit3
- License: mit
- Created: 2021-08-20T07:35:35.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2025-08-28T12:38:23.000Z (9 months ago)
- Last Synced: 2025-09-25T10:47:37.578Z (8 months ago)
- Topics: python, stopwatch
- Language: Python
- Homepage: https://blog.openacid.com
- Size: 37.1 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# k3stopwatch
[](https://github.com/pykit3/k3stopwatch/actions/workflows/python-package.yml)
[](https://k3stopwatch.readthedocs.io/en/stable/?badge=stable)
[](https://pypi.org/project/k3stopwatch)
StopWatch - library for adding timers and tags in your code for performance monitoring
k3stopwatch is a component of [pykit3] project: a python3 toolkit set.
StopWatch operates on a notion of "spans" which represent scopes of code for which we
want to measure timing. Spans can be nested and placed inside loops for aggregation.
StopWatch requires a root scope which upon completion signifies the end of the round
of measurements. On a server, you might use a single request as your root scope.
StopWatch produces two kinds of reports.
1) Aggregated (see _reported_values).
2) Non-aggregated or "tracing" (see _reported_traces).
# Install
```
pip install k3stopwatch
```
# Synopsis
```python
import k3stopwatch
sw = k3stopwatch.StopWatch()
with sw.timer('rwoot'):
for i in range(50):
with sw.timer('inner_task'):
print("do_inner_task(i)")
```
# Author
Zhang Yanpo (张炎泼)
# Copyright and License
The MIT License (MIT)
Copyright (c) 2015 Zhang Yanpo (张炎泼)
[pykit3]: https://github.com/pykit3