VHISTlib
1.84.0.3018
|
This example shows how to measure time intervals using the StopWatch class.
/* $HEADERS $Id: stopwatch_example.cpp 2179 2011-06-24 09:03:24Z ahuesgen $ */ #include <shared/stopwatch.h> #include <QObject> // this class will handle our performance measurement results class Logger : public QObject { Q_OBJECT public slots: void log(const QString msg, const int type); }; void Logger::log(const QString msg, const int type) { // do something with the log messages std::cout << msg.toStdStr() << std::endl; } // ... // create a logger Logger logger; // create a stopwatch vhist::StopWatch watch(&logger); // start timing watch.start("first performance test"); doSomeStuff(); // this call will stop the first timing sequence watch.start("second performance test"); doOtherStuff(); // explicitly stop the last timing sequence watch.stop();