Skip to main content

This project provides a simple way to profile the execution time of your Python functions.

Project description

Time Logger

This project provides a simple way to profile the execution time of your Python functions.

Features

  • Measure the execution time of functions with the @profiling decorator.
  • Optionally log the start and end times of function execution.
  • Log specific variables or all arguments passed to the function.
  • Choose between using the standard print function or a custom logger for output.

Installation

pip install -e .

Usage

from time_logger import profiling

# Basic usage
@profiling()
def my_function():
    # Your code here

# Log start and end times
@profiling(log_start=True)
def my_function():
    # Your code here

# Log specific variables
@profiling(log_variables=['my_variable'])
def my_function(my_variable):
    # Your code here

# Log all arguments
@profiling(log_all_args=True)
def my_function(arg1, arg2):
    # Your code here

# Use a custom logger
import logging

logger = logging.getLogger(__name__)
handler = logging.StreamHandler()
logger.addHandler(handler)

@profiling(logger=logger)
def my_function():
    # Your code here

Examples

See the tests/test_profiling.py file for more examples.

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

pytime_logger-0.0.2.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

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

pytime_logger-0.0.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file pytime_logger-0.0.2.tar.gz.

File metadata

  • Download URL: pytime_logger-0.0.2.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for pytime_logger-0.0.2.tar.gz
Algorithm Hash digest
SHA256 5c8ecf82f71b679a85b50ee1feaa13e1ab9b9f271526c2ea587c4b2e03f7033c
MD5 a92bc074b547a21222f340f6c8cd075b
BLAKE2b-256 00c5ec7cd4e4324e2bc6d720e66d2fabc96b1bf79b09dbd02ab72952b22660ab

See more details on using hashes here.

File details

Details for the file pytime_logger-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pytime_logger-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for pytime_logger-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0b1398e047d3fc04fb1057ae27d22747373a6ce93c344d7ccaf7ff3fa7a77ddc
MD5 1dc70cd5ac91afd5da5569fc16af9267
BLAKE2b-256 1907f71bf2fc038dd76c43dcb38acb8b9413ee1ece85386b34777d32d5136ce3

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