src/testlib/qbenchmark_p.h
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
equal deleted inserted replaced
27:93b982ccede2 31:5daf16870df6
    40 ****************************************************************************/
    40 ****************************************************************************/
    41 
    41 
    42 #ifndef QBENCHMARK_P_H
    42 #ifndef QBENCHMARK_P_H
    43 #define QBENCHMARK_P_H
    43 #define QBENCHMARK_P_H
    44 
    44 
       
    45 #include <stdlib.h>
       
    46 
    45 //
    47 //
    46 //  W A R N I N G
    48 //  W A R N I N G
    47 //  -------------
    49 //  -------------
    48 //
    50 //
    49 // This file is not part of the Qt API.  It exists purely as an
    51 // This file is not part of the Qt API.  It exists purely as an
    66 #include <QtTest/qtest_global.h>
    68 #include <QtTest/qtest_global.h>
    67 #ifdef QTESTLIB_USE_VALGRIND
    69 #ifdef QTESTLIB_USE_VALGRIND
    68 #include "QtTest/private/qbenchmarkvalgrind_p.h"
    70 #include "QtTest/private/qbenchmarkvalgrind_p.h"
    69 #endif
    71 #endif
    70 #include "QtTest/private/qbenchmarkevent_p.h"
    72 #include "QtTest/private/qbenchmarkevent_p.h"
       
    73 #include "QtTest/private/qbenchmarkmetric_p.h"
    71 
    74 
    72 QT_BEGIN_NAMESPACE
    75 QT_BEGIN_NAMESPACE
    73 
    76 
    74 struct QBenchmarkContext
    77 struct QBenchmarkContext
    75 {
    78 {
    90 
    93 
    91 class QBenchmarkResult
    94 class QBenchmarkResult
    92 {
    95 {
    93 public:
    96 public:
    94     QBenchmarkContext context;
    97     QBenchmarkContext context;
    95     qint64 value;
    98     qreal value;
    96     int iterations;
    99     int iterations;
       
   100     QTest::QBenchmarkMetric metric;
       
   101     bool setByMacro;
    97     bool valid;
   102     bool valid;
    98 
   103 
    99     QBenchmarkResult()
   104     QBenchmarkResult()
   100     : value(-1)
   105     : value(-1)
   101     , iterations(-1)
   106     , iterations(-1)
       
   107     , setByMacro(true)
   102     , valid(false)
   108     , valid(false)
   103     {  }
   109     { }
   104 
   110 
   105     QBenchmarkResult(const QBenchmarkContext &context, const qint64 value, const int iterations)
   111     QBenchmarkResult(
       
   112         const QBenchmarkContext &context, const qreal value, const int iterations,
       
   113         QTest::QBenchmarkMetric metric, bool setByMacro)
   106         : context(context)
   114         : context(context)
   107         , value(value)
   115         , value(value)
   108         , iterations(iterations)
   116         , iterations(iterations)
       
   117         , metric(metric)
       
   118         , setByMacro(setByMacro)
   109         , valid(true)
   119         , valid(true)
   110     {
   120     { }
   111     }
       
   112 
   121 
   113     bool operator<(const QBenchmarkResult &other) const 
   122     bool operator<(const QBenchmarkResult &other) const 
   114     {
   123     {
   115         return (value / iterations) < (other.value / other.iterations);
   124         return (value / iterations) < (other.value / other.iterations);
   116     }
   125     }
   165     void endDataRun();
   174     void endDataRun();
   166 
   175 
   167     bool isBenchmark() const { return result.valid; }
   176     bool isBenchmark() const { return result.valid; }
   168     bool resultsAccepted() const { return resultAccepted; }
   177     bool resultsAccepted() const { return resultAccepted; }
   169     int adjustIterationCount(int suggestion);
   178     int adjustIterationCount(int suggestion);
   170     void setResult(qint64 value);
   179     void setResult(qreal value, QTest::QBenchmarkMetric metric, bool setByMacro = true);
   171 
   180 
   172     QBenchmarkResult result;
   181     QBenchmarkResult result;
   173     bool resultAccepted;
   182     bool resultAccepted;
   174     bool runOnce;
   183     bool runOnce;
   175     int iterationCount;
   184     int iterationCount;
   181     int iterationCount();
   190     int iterationCount();
   182     void setIterationCountHint(int count);
   191     void setIterationCountHint(int count);
   183     void setIterationCount(int count);
   192     void setIterationCount(int count);
   184 
   193 
   185     Q_TESTLIB_EXPORT void beginBenchmarkMeasurement();
   194     Q_TESTLIB_EXPORT void beginBenchmarkMeasurement();
   186     Q_TESTLIB_EXPORT qint64 endBenchmarkMeasurement();
   195     Q_TESTLIB_EXPORT quint64 endBenchmarkMeasurement();
   187 
       
   188     void setResult(qint64 result);
       
   189     void setResult(const QString &tag, qint64 result);
       
   190 }
   196 }
   191 
   197 
   192 QT_END_NAMESPACE
   198 QT_END_NAMESPACE
   193 
   199 
   194 #endif // QBENCHMARK_H
   200 #endif // QBENCHMARK_H