🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

timerpy

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timerpy

Measure execution time of code sections.

1.1.0
PyPI
Maintainers
1

timerpy

Measure execution time of code sections.

Installation

python3 -m pip install timerpy

Usage Examples


from timerpy import Timer
with Timer():
    # Some code

>>>TIME ELAPSED: 0:00:01.199748


# Specify message
with Timer('HELLO WORLD'):
    # Some code

>>>HELLO WORLD TIME ELAPSED: 0:02:15.242731


# Specify output
from logging import info # Write to log file
with Timer('HELLO WORLD', info):
    # Some code

>>>timer.py: INFO: stop(): 44:	HELLO WORLD TIME ELAPSED: 0:00:01.200157


# Get elapsed time as float value
with Timer() as timer1:
    # Some code
nanoseconds = timer1.elapsed_time
print(nanoseconds)

>>>TIME ELAPSED: 0:00:01.400193
>>>1400192600

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