Skip to content

A simple wrapper to time how long methods occur. This is designed for methods that take seconds not micro-seconds.

Notifications You must be signed in to change notification settings

carvetighter/Timer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TimerWrapper

This is a very small package and is designed to time different parts of code that take more than a second. This package is not intended to replace timeit or any other timer. This is intended for developers to make debugging a bit easier.

Installation

pip install TimerWrapper

Usage

Example 01:

from TimerWrapper import Timer

timer_00 = Timer()
<block of code>
float_time = timer_00.stop()
print(float_time)

Example 01 Output (5 seconds):

<code output>
5.0

Example 02:

from TimerWrapper import Timer

timer_01 = Timer('added text')
<block of code>
timer_01.stop_timer(m_bool_print = True)

Example 02 Output (5 seconds):

<code output>
process time is: 00:00:05 added text

Clearing the timer:

You can use the same instance to time additonal code blocks. You must clear the timer first.

from TimerWrapper import Timer

timer_01 = Timer()
<block of code>
float_time_00 = timer_01.stop_timer()

timer_01.clear_timer()
timer_01.start_timer()
<block of code>
float_time_01 = timer_01.stop_timer()

float_time_00 and float_time_01 are different.

About

A simple wrapper to time how long methods occur. This is designed for methods that take seconds not micro-seconds.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages