Measuring Performance using QTimer

If you ever need to do light-weight profiling of your QCubed application, you might find the QTimer class useful. It's really simple: you can start a named timer by doing QTimer::start('timerName'); you can stop it; you can restart the timer later if you want to. When you're done measuring a section of your code, just call QTimer::getTime('timerName'). If you had several timers running, an easy way to dump all the interesting debug info is to call QTimer::varDump().

Each of the timers is internall maintained as a QTimer object. If you want to know more about the timers - for example, the number of times the timer was started - you can get the QTimer object instance, and then interrogating that instance:

$objTimer = QTimer::GetTimer('timerName');
echo $objTimer->CountStarted;

Take a look at a sample usage example below by clicking View Source.

Here's how long it took to execute the long calculation: 0.193922996521

Results of QTimer::varDump():
longCalculation - start count: 2 - execution time: 0.385986
loadPersons - start count: 1 - execution time: 0.012983