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.1.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.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytime_logger-0.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 1ea6171f403bf44870ba6ca9aac670f90b5dc846cd441ec5e0cac0030ccd0184
MD5 5fb542bbcdca158732a6c59703a4e39a
BLAKE2b-256 0311b0a8e209b9a115d7e4e5483abf5657cb6b2d51f718e83054f67266e895e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytime_logger-0.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4d7378a8e1dfa8ed5f2efacc8b7e8f5dbc2ece75e9ca46161d83ba9e9c78d8c7
MD5 64457ab2bb993cdd5bd48eeb67f60410
BLAKE2b-256 347ce1b8eb697a8837b1827468d50a46fe35fcd23934dc13a744cfb431b65f54

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