Runtime Profiler

MV3D includes a runtime profiler that can be used to gather profiling results from servers, clients, and even tools. For servers, the results are conveniently relayed to the Overseer tool so that multiple servers can be monitored this way at once. The profiling is also optimized out when running in optimize mode (python -o). Since this the profiling is done in Python code, some markup is required in order to start timing each section of code. However, this is made easy by the @timed decorator.

Example Usage

from mv3d.util.profiler import timed, theProfiler

@timed
def doStuff(iters):
    """
    Perform some random work here to take up time.
    """
    for _ in range(iters):
        res = 0
        for x in range(20):
            res += res * x

# call the function
doStuff(100)
# Print out the top 20 entries (which should only be one run of doStuff
for entry in theProfiler.top():
    print entry

Normally, all that is needed is to mark up whatever functions should be profiled with @profile and then in Overseer or the client, pop up the stats window. Overseer has a button for it, and in the client, you need to bring up the console with ` and then type showDebug(conductor).