metawards.utils.Profiler

class metawards.utils.Profiler(name: Optional[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: Optional[str] = None, parent=None)[source]

Methods

__delattr__(name, /)

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__(value, /)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__init__([name, parent])

__init_subclass__

This method is called when a class is subclassed.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__ne__(value, /)

Return self!=value.

__new__(**kwargs)

__reduce__()

Helper for pickle.

__reduce_ex__(protocol, /)

Helper for pickle.

__repr__()

Return repr(self).

__setattr__(name, value, /)

Implement setattr(self, name, value).

__sizeof__()

Size of object in memory, in bytes.

__str__()

Return the results of profiling as a report

__subclasshook__

Abstract classes can override this to customize issubclass().

_to_string()

Used to write the results of profiling as a report

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)

Attributes

__dict__

__doc__

__module__

__weakref__

list of weak references to the object (if defined)

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

Return the results of profiling as a report

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)