A small python timing package for a packaging demonstration
Project description
smalltime
What is it?
smalltime
is a quick and dirty library for timing Python function, sections of code and arbitrary programs on the command line.
Requirements
smalltime
requires Python >= 3.6.2.
See pyproject.toml
for dependencies and dev dependencies.
Installation
Via poetry
:
poetry add smalltime
Via pip
:
pip install smalltime
Basic Usage
In Python Code
In-Line
import smalltime
timer = smalltime.Timer(name="hello world timer")
timer.start()
print("Hello, ", end="")
print("World!")
timer.stop()
Via Decorator
import smalltime
import subprocess
@smalltime.timed(name="thing_timer")
def thing_you_want_to_time():
subprocess.call(["python", "-c", "\"import this\""])
thing_you_want_to_time()
From the Command Line
N.B.: Assumes installation via Poetry and an active Poetry shell.
# Usage: st <program> [args]
st sleep 10
Starting counter (BNM8rBqP)
Counter stopped (BNM8rBqP): 10007777130ns elapsed
Can I use this in my project?
Yes, please do! The code is all open source and BSD-3-Clause licensed.
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
smalltime-0.0.3.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for smalltime-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddb6f562a1713cd42fc0b1a57c04d11c8e7a0752805f4cf3c62da4e6d6cf48e6 |
|
MD5 | c674facd1eab5a334fd4972d2abb9fc0 |
|
BLAKE2b-256 | 8b975bbd31f232322eb6705a5dfa883e60b1c981a5e49091dc89752ba10cd81e |