Home > Uncategorized > Creating a Benchmark

Creating a Benchmark

September 15th, 2009 Leave a comment Go to comments

To create a benchmark, follow the instructions for crating a test and then add a QBENCHMARK macro to the test function that you want to benchmark.

class MyFirstBenchmark: public QObject
{
  Q_OBJECT;
  private slots:
   void myFirstBenchmark()
   {
     QString string1;
     QString string2;
     QBENCHMARK
     {
       string1.localeAwareCompare(string2);
     }
   }
};

The code insde the QBENCHMARK macro will be measured, and possibly also repeated several times in order to get an accurate measurement. This depends on the selected measurement back-end. Several back-ends are available an can be selected on the command line.

Documentation

Tags:
  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.