Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (5.4%) to scientific vocabulary
Keywords
Repository
Python code timer, support block wise and function wise
Basic Info
- Host: GitHub
- Owner: LucienShui
- License: apache-2.0
- Language: Python
- Default Branch: main
- Homepage: https://pypi.org/project/timer/
- Size: 26.4 KB
Statistics
- Stars: 16
- Watchers: 2
- Forks: 2
- Open Issues: 2
- Releases: 10
Topics
Metadata Files
README.md
Timer
Python code timer, support block wise and function wise
Installation
shell
pip install timer
Usage
import
py from timer import timerdecorate without brackets
py @timer def func(): ...decorate with brackets
py @timer() def func(): ...decorate with name and time unit
py @timer('function name', 's') def func(): ...decorate with key word arguments
py @timer(name='function name', unit='s') def func(): ...block wise without object
py with timer(): ...block wise with object
py with timer() as t: ... print(t.elapse)
Sample Code
```python import logging import time
from timer import timer, get_timer
default timer's logging level is logging.DEBUG
so timer would print nothing if logging level is logging.INFO or higher
logging.basicConfig(level=logging.DEBUG)
or you can change default timer's logging level
timer.set_level(logging.DEBUG)
also you can get a timer with custom logging level with get_timer(level)
warningtimer = gettimer(logging.WARNING)
explicit the timer's name and it's time unit
@timer('function:add', unit='s') def add(a, b): time.sleep(.1) return a + b
function name is timer's name for default
@timer def sub(a, b): time.sleep(.1) return a - b
if name == 'main': # 'timer' would be timer's name by default with timer('time.sleep(2)') as t: print(3) time.sleep(1) print(f'after time.sleep(1) once, t.elapse = {t.elapse}') time.sleep(1) print(f'after time.sleep(1) twice, t.elapse = {t.elapse}') print(f'after with, t.elapse = {t.elapse}')
with warning_timer('test'):
pass
print(add(1, 1))
print(sub(2, 1))
```
Outputs
plain
3
after time.sleep(1) once, t.elapse = 1.003798776
after time.sleep(1) twice, t.elapse = 2.0052743459999998
DEBUG:timer.time.sleep(2): 2.006 s
after with, t.elapse = 2.005628447
WARNING:timer.test:start
WARNING:timer.test:cost 0 ms
DEBUG:timer.function:add: 0.105 s
2
DEBUG:timer.sub: 102 ms
1
Special Thanks
Owner
- Name: Lucien
- Login: LucienShui
- Kind: user
- Location: Hangzhou
- Company: @alibaba
- Website: https://lucien.ink
- Repositories: 13
- Profile: https://github.com/LucienShui
因为孤独是人之常态,所以陪伴才显得尤为珍贵。
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Committers
Last synced: almost 3 years ago
All Time
- Total Commits: 23
- Total Committers: 1
- Avg Commits per committer: 23.0
- Development Distribution Score (DDS): 0.0
Top Committers
| Name | Commits | |
|---|---|---|
| Lucien Shui | l****n@l****k | 23 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 3
- Total pull requests: 10
- Average time to close issues: about 6 hours
- Average time to close pull requests: about 2 months
- Total issue authors: 3
- Total pull request authors: 2
- Average comments per issue: 0.67
- Average comments per pull request: 0.3
- Merged pull requests: 9
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- crowmagnumb (1)
- christophevg (1)
- furechan (1)
Pull Request Authors
- LucienShui (9)
- christophevg (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 11,673 last-month
- Total docker downloads: 149
- Total dependent packages: 2
- Total dependent repositories: 65
- Total versions: 9
- Total maintainers: 2
pypi.org: timer
Python Code Timer
- Homepage: https://github.com/LucienShui/timer
- Documentation: https://timer.readthedocs.io/
- License: apache-2.0
-
Latest release: 0.3.0
published almost 2 years ago
Rankings
Maintainers (2)
Dependencies
- actions/checkout v2 composite
- actions/setup-python v2 composite
- release-drafter/release-drafter v5 composite