I am working on QGIS. I need to determine how much time QGIS needed to finish a specific task. I have been unable to get execution times for the processes. What is the proper way to get processing time under QGIS?
What kind of tasks are you referring to?
I use the following static class to benchmark my code.
I designed it to be static so that I can call the start/stop/show methods wherever is needed without worrying about passing references to the Timer back and forth.
The optional parameters allow me to have several running at once, any values will do but names look nicer.
Sometimes its necessary to create a stub method and connect it to a signal in order to call these methods at the right moment, but without knowing more about what you are timing its hard to be specific.
from PyQt4.QtGui import * from datetime import datetime class Timer(): startTimes=dict() stopTimes=dict() @staticmethod def start(key = 0): Timer.startTimes[key] = datetime.now() Timer.stopTimes[key] = None @staticmethod def stop(key = 0): Timer.stopTimes[key] = datetime.now() @staticmethod def show(key = 0): if key in Timer.startTimes: if Timer.startTimes[key] is not None: if key in Timer.stopTimes: if Timer.stopTimes[key] is not None: delta = Timer.stopTimes[key] - Timer.startTimes[key] QMessageBox.information(None,"Timer: " + str(key), str(delta))