Skip to main content

Clock Timmer

CI

Clock Timmer is a Python library that provides a tool for logging the time and number of calls of a function in Python. It can be used as a decorator or context manager, allowing you to log the time and number of calls of a function or block of code without modifying any lines of code within the function or block.

Installation To install Clock Timmer, use the following command:

pip install python-clock-timer

Usage

As a decorator

To use Clock Timmer as a decorator, you can use it like this:

from clock_timer import ClockLogger

logger = ClockLogger()

@logger
def my_function():
    # code of the function

After using the decorator, you can access the time and number of calls logs of the function by accessing the log attribute of the Clock Timmer object. For example, to get the number of calls and total time elapsed of the my_function, you can do the following:

print(logger.log['my_function'])

As a context manager

To use Clock Timmer as a context manager, you can use it like this:

from clock_timer import ClockLogger

with ClockLogger() as logger:
# code of the block

print(logger.total_elapsed)

After using the context manager, you can access the total time elapsed by accessing the elapsed attribute of the Clock Timmer object.

Example

Here is an example of using Clock Timmer as a decorator and a context manager:

from clock_timer import ClockLogger
import time

# Using Clock Timmer as a decorator
logger = ClockLogger()

@logger
def my_function():
    time.sleep(1)

my_function()
my_function()

print(logger.log['my_function'])

the output

my_function was called 1 times, total time elapsed: 1.005031s
my_function was called 2 times, total time elapsed: 2.005123s
[2, 2.0051226250000003]

Using Clock Timmer as a context manager

import time

from clock_timer import ClockLogger

with ClockLogger() as logger:
    time.sleep(1)

print(logger.total_elapsed)

The output of this example will be:

Total time elapsed: 1.003622s
1.003622042

Contributing

We welcome contributions to Clock Timmer. If you have any ideas for improvements or want to report a bug, please open an issue or submit a pull request.

License

Clock Timmer is licensed under the MIT License. See the LICENSE file for more details.

Metadata

Release files for python-clock-timer 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-clock-timer 0.4.0
File Size Uploaded Provenance
python-clock-timer-0.4.0.tar.gz 5.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for python-clock-timer 0.4.0
File Interpreter ABI Platform
python_clock_timer-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.5 kB

Release files / python-clock-timer-0.4.0.tar.gz

Download URL python-clock-timer-0.4.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
47252a3482de118b9e9093bfad110e3eacf71c84ed632ea407bd28bd6ade2c6e
BLAKE2b-256 checksum
How to use checksums
1a145f86a4a22ed4f1b1e2fb9eeafd9de69bee049cb87561f81871c4c7f024d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / python_clock_timer-0.4.0-py3-none-any.whl

Download URL python_clock_timer-0.4.0-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ff77f4ef75694ad99a8147bf13fd7ef0c1c928a9fecd4bc3c0e7105ce2c03c8
BLAKE2b-256 checksum
How to use checksums
ab2888897806439fdfc9d5df2c4a60afced32cfafeac5f07e41a2d771baef4e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Security for python-clock-timer 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page