Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pytimers

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pytimers

Measuring time to run functions, methods or blocks of code made easy.

  • 3.1
  • PyPI
  • Socket score

Maintainers
1

Pytimers

.. inclusion-marker-start

Pytimers is a python micro library that allows you to quickly measure time to run functions, methods or individual blocks of codes. Here's a quick demo.

.. code-block:: python

import logging
from time import sleep

from pytimers import timer

logging.basicConfig(level=logging.INFO)


@timer
def foo() -> None:
    print("Some heavy lifting.")
    sleep(2)


if __name__ == "__main__":

    print("Let's call the function decorated with timer.")
    foo()

    print("Use timer context manager.")
    with timer.label("sleeping block"):
        print("Some more work to do.")
        sleep(1)

.. code-block:: console

Let's call the function decorated with timer.
Some heavy lifting.
INFO:pytimers.triggers.logger_trigger:Finished foo in 2s 0.494ms [2.0s].
Use timer context manager.
Some more work to do.
INFO:pytimers.triggers.logger_trigger:Finished sleeping block in 1s 1.247ms [1.001s].

.. inclusion-marker-end

See the full Documentation <https://pytimers.readthedocs.io/en/latest/>_.

Build Status


.. image:: https://github.com/michalfilippi/pytimers/actions/workflows/test.yml/badge.svg
   :alt: Unit Tests
   :align: left

|

.. image:: https://github.com/michalfilippi/pytimers/actions/workflows/code_style.yml/badge.svg
   :alt: Code Style Check
   :align: left

|

PyPi
~~~~

.. image:: https://img.shields.io/pypi/v/pytimers.svg
   :target: https://pypi.python.org/pypi/pytimers/
   :alt: PyPi
   :align: left

|

.. image:: https://img.shields.io/pypi/l/pytimers.svg
   :target: https://pypi.python.org/pypi/pytimers/
   :alt: PyPI - License
   :align: left

|

.. image:: https://img.shields.io/pypi/pyversions/pytimers.svg
   :target: https://pypi.python.org/pypi/pytimers/
   :alt: PyPi - Python Version
   :align: left

|

.. image:: https://img.shields.io/pypi/implementation/pytimers.svg
   :target: https://pypi.python.org/pypi/pytimers/
   :alt: PyPi - Implementation
   :align: left

|


FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc