timer module

Largely this module was simply practice on writing decorators.

Might need to review logging best practices. I don’t want the logger from this module to emit anything, but it seems tedious to place that burden on any module that imports from here.

timer(func)[source][source]

Print the runtime of the decorated function.

Utilizes time.perf_counter.

Todo

Begin using the timeit module.

There are more specialized ways of profiling things in other modules; however, this works for a rough estimate.

Parameters

func (function) – Function to profile

Returns

value – Output of function time.perf_counter().

Return type

float

debug(func)[source][source]

Print the function signature and return value

exc_timer(statement, setup=None)[source][source]

A non-decorator implementation that uses timeit.

class ArgReparser(func)[source][source]

Bases: object

Class decorator that echoes out the arguments a function was called with.

__init__(func)[source][source]

Initialize the reparser with the function it wraps.

time_dir(directory=None)[source][source]

How long does it take to exec(compile(file)) every file in the startup dir?

class LineWatcher[source][source]

Bases: object

Class that implements a basic timer.

Registers the start and stop methods with the IPython events API.

__init__()[source][source]

Define the classes start_time parameter.

start()[source][source]

Return time.time.

stop()[source][source]

Determine the difference between start time and end time.

load_ipython_extension(ip=None, line_watcher=None)[source][source]

Initialize a LineWatcher and register start and stop with IPython.

unload_ipython_extension(ip=None, line_watcher=None)[source][source]