metawards.utils.Profiler

class metawards.utils.Profiler(name: str = None, parent=None)[source]

This is a simple profiling class that supports manual instrumenting of the code. It is used for sub-function profiling.

__init__(name: str = None, parent=None)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(name[, parent]) Initialize self.
child_total() Return the sum of time spent in the child profilers
is_null() Return whether this is a null profiler
name() Return the name of this profiler
start(name) Start profiling the section called ‘name’.
stop() Stop profiling.
total() Return the amount of time that was recorded for this profiler in milliseconds (accurate to ~nanoseconds)
child_total() → float[source]

Return the sum of time spent in the child profilers

is_null() → bool[source]

Return whether this is a null profiler

name() → str[source]

Return the name of this profiler

start(name: str)[source]

Start profiling the section called ‘name’. This returns the updated profiler, e.g.

p = Profiler()

p = p.start(“long_loop”)

# run some code

p = p.end()

print(p)

stop()[source]

Stop profiling. This records the end time and returns the parent profiler (if we have one)

total() → float[source]

Return the amount of time that was recorded for this profiler in milliseconds (accurate to ~nanoseconds)