Changeset 846 for trunk/src/testlib/qbenchmark.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/testlib/qbenchmark.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 42 42 #include "QtTest/qbenchmark.h" 43 43 #include "QtTest/private/qbenchmark_p.h" 44 #include "QtTest/private/qbenchmarkmetric_p.h" 44 45 45 46 #ifdef QT_GUI_LIB … … 139 140 int QBenchmarkTestMethodData::adjustIterationCount(int suggestion) 140 141 { 141 // Let the -iteration -countoption override the measurer.142 // Let the -iterations option override the measurer. 142 143 if (QBenchmarkGlobalData::current->iterationCount != -1) { 143 144 iterationCount = QBenchmarkGlobalData::current->iterationCount; … … 149 150 } 150 151 151 void QBenchmarkTestMethodData::setResult(qint64 value) 152 void QBenchmarkTestMethodData::setResult( 153 qreal value, QTest::QBenchmarkMetric metric, bool setByMacro) 152 154 { 153 155 bool accepted = false; 154 156 155 157 // Always accept the result if the iteration count has been 156 // specified on the command line with -ite artion-count.158 // specified on the command line with -iterations. 157 159 if (QBenchmarkGlobalData::current->iterationCount != -1) 158 160 accepted = true; 159 161 160 if (QBenchmarkTestMethodData::current->runOnce) {162 else if (QBenchmarkTestMethodData::current->runOnce || !setByMacro) { 161 163 iterationCount = 1; 162 164 accepted = true; 163 165 } 164 166 165 167 // Test the result directly without calling the measurer if the minimum time 166 // has been specif ed on the command line with -minimumvalue.168 // has been specified on the command line with -minimumvalue. 167 169 else if (QBenchmarkGlobalData::current->walltimeMinimum != -1) 168 170 accepted = (value > QBenchmarkGlobalData::current->walltimeMinimum); … … 176 178 iterationCount *= 2; 177 179 178 this->result = 179 QBenchmark Result(QBenchmarkGlobalData::current->context, value, iterationCount);180 this->result = QBenchmarkResult( 181 QBenchmarkGlobalData::current->context, value, iterationCount, metric, setByMacro); 180 182 } 181 183 … … 209 211 QTest::QBenchmarkIterationController::~QBenchmarkIterationController() 210 212 { 211 QBenchmarkTestMethodData::current->setResult(QTest::endBenchmarkMeasurement()); 213 const qreal result = QTest::endBenchmarkMeasurement(); 214 QBenchmarkTestMethodData::current->setResult(result, QBenchmarkGlobalData::current->measurer->metricType()); 212 215 } 213 216 … … 260 263 /*! \internal 261 264 */ 262 q int64 QTest::endBenchmarkMeasurement()265 quint64 QTest::endBenchmarkMeasurement() 263 266 { 264 267 // the clock is ticking before the line below, don't add code here. … … 266 269 } 267 270 268 /*! \internal 269 */ 270 void QTest::setResult(qint64 result) 271 { 272 QBenchmarkTestMethodData::current->setResult(result); 273 } 274 275 /*! \internal 276 */ 277 void QTest::setResult(const QString &tag, qint64 result) 278 { 279 QBenchmarkContext context = QBenchmarkGlobalData::current->context; 280 context.tag = tag; 281 QBenchmarkTestMethodData::current->result = 282 QBenchmarkResult( context, result, 283 QBenchmarkTestMethodData::current->iterationCount); 271 /*! 272 Sets the benchmark result for this test function to \a result. 273 274 Use this function if you want to report benchmark results without 275 using the QBENCHMARK macro. Use \a metric to specify how QTestLib 276 should interpret the results. 277 278 The context for the result will be the test function name and any 279 data tag from the _data function. This function can only be called 280 once in each test function, subsequent calls will replace the 281 earlier reported results. 282 283 Note that the -iterations command line argument has no effect 284 on test functions without the QBENCHMARK macro. 285 286 \since 4.7 287 */ 288 void QTest::setBenchmarkResult(qreal result, QTest::QBenchmarkMetric metric) 289 { 290 QBenchmarkTestMethodData::current->setResult(result, metric, false); 284 291 } 285 292 … … 299 306 } 300 307 301 302 308 QT_END_NAMESPACE 303
Note:
See TracChangeset
for help on using the changeset viewer.