vispy.util.profiler module#

class vispy.util.profiler.Profiler(msg=None, disabled='env', delayed=True)#

Bases: object

Simple profiler allowing directed, hierarchical measurement of time intervals.

By default, profilers are disabled. To enable profiling, set the environment variable VISPYPROFILE to a comma-separated list of fully-qualified names of profiled functions.

Calling a profiler registers a message (defaulting to an increasing counter) that contains the time elapsed since the last call. When the profiler is about to be garbage-collected, the messages are passed to the outer profiler if one is running, or printed to stdout otherwise.

If delayed is set to False, messages are immediately printed instead.

Example:
def function(…):

profiler = Profiler() … do stuff … profiler(‘did stuff’) … do other stuff … profiler(‘did other stuff’) # profiler is garbage-collected and flushed at function end

If this function is a method of class C, setting VISPYPROFILE to “C.function” (without the module name) will enable this profiler.

For regular functions, use the qualified name of the function, stripping only the initial “vispy..” prefix from the module.

class DisabledProfiler(*args, **kwds)#

Bases: object

finish()#
mark(msg=None)#
disable = False#
finish(msg=None)#

Add a final message; flush the message list if no parent profiler.

flush()#
mark(msg=None)#