Skip to main content

Timing Utilities

Project description

timepkg

The official repository fof the timepkg python package!

Installation

pip install timepkg

Usage

Timekeeper

import time
from timepkg import timekeeper


@timekeeper
def function():
    print("Hello World!")
    ...
    time.sleep(1)
    return "Goodbye!"


result = function()
print(result)
return_value, execution_time = function()
print(return_value, execution_time)
Hello World!
KeeperResult(return_value='Goodbye!', execution_time=1.0127643000000002)
Hello World!
Goodbye! 1.0116009

Guardian

import time
from timepkg import guardian


@guardian(save_metadata=True, guarded_exceptions=[ValueError])
def function():
    print("Hello World!")
    ...
    time.sleep(1)
    raise ValueError("Error!")


result = function()
print(result)
return_value, execution_time, (start_time, end_time, raised_exception) = function()
print(return_value, execution_time, start_time, end_time, raised_exception)
Hello World!
GuardianResult(return_value=None, execution_time=1.00541090965271, metadata=GuardianMetadata(start_time=1720282040.3592346, end_time=1720282041.3646455, raised_exception=ValueError('Error!',)))
Hello World!
None 1.0010006427764893 1720282041.3646455 1720282042.3656461 Error!

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

timepkg-0.3.2.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

timepkg-0.3.2-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file timepkg-0.3.2.tar.gz.

File metadata

  • Download URL: timepkg-0.3.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1022-azure

File hashes

Hashes for timepkg-0.3.2.tar.gz
Algorithm Hash digest
SHA256 d0e3191e647d13e43b7beea6db8feb59086ffedb6addf8ee96f1e42b497c30bc
MD5 4ad0fc1242ef4d64cd2ffdd53d2b435f
BLAKE2b-256 b19ab91a39bfc2dce713d85769340a9b849518b1880e9b9aea2666a6ddf67b26

See more details on using hashes here.

File details

Details for the file timepkg-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: timepkg-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1022-azure

File hashes

Hashes for timepkg-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d10be6225c847447cf90a7c206fe9cd5187b83a7aaab0ee6074ce1ae97043179
MD5 b6498cde59f0a6e015ef2fec772b46f5
BLAKE2b-256 24c8c9c6d35d6c1d3076d4714802f92b772a10ccd3501a3430fa4e24505948de

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page