Disable component outputs to improve computation performance

You can delete any calls to these functions. If they’re not functions (i.e. chunks of code within some larger scope) you can comment them out instead. If the performance issue is that outputting the data is the expensive part (it might be), you can remove the output entirely (i.e. using the ZUI), wrap the data in something less expensive, or simply set the data of the output variable to None at the end of the script.

First step though is profiling the code to identify the actual bottlenecks. You can use something like this stopwatch to do this:

import time

class Timer(object):
    
    """ A simple profiler """
    
    def start(self):

        # Start the timer
        self.startTime = time.time()
        
    def stop(self):
        
        # Print an return elapsed time
        elapsedSeconds = time.time() - self.startTime
        elapsedMilliseconds = elapsedSeconds*1000
        print str(round(elapsedMilliseconds,3)) + " ms"
        return elapsedMilliseconds
2 Likes