Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/testlib/qbenchmark.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4242#include "QtTest/qbenchmark.h"
    4343#include "QtTest/private/qbenchmark_p.h"
     44#include "QtTest/private/qbenchmarkmetric_p.h"
    4445
    4546#ifdef QT_GUI_LIB
     
    139140int QBenchmarkTestMethodData::adjustIterationCount(int suggestion)
    140141{
    141     // Let the -iteration-count option override the measurer.
     142    // Let the -iterations option override the measurer.
    142143    if (QBenchmarkGlobalData::current->iterationCount != -1) {
    143144        iterationCount = QBenchmarkGlobalData::current->iterationCount;
     
    149150}
    150151
    151 void QBenchmarkTestMethodData::setResult(qint64 value)
     152void QBenchmarkTestMethodData::setResult(
     153    qreal value, QTest::QBenchmarkMetric metric, bool setByMacro)
    152154{
    153155    bool accepted = false;
    154156
    155157    // Always accept the result if the iteration count has been
    156     // specified on the command line with -iteartion-count.
     158    // specified on the command line with -iterations.
    157159    if (QBenchmarkGlobalData::current->iterationCount != -1)
    158160        accepted = true;
    159161
    160     if (QBenchmarkTestMethodData::current->runOnce) {
     162    else if (QBenchmarkTestMethodData::current->runOnce || !setByMacro) {
    161163        iterationCount = 1;
    162164        accepted = true;
    163165    }
    164    
     166
    165167    // Test the result directly without calling the measurer if the minimum time
    166     // has been specifed on the command line with -minimumvalue.
     168    // has been specified on the command line with -minimumvalue.
    167169    else if (QBenchmarkGlobalData::current->walltimeMinimum != -1)
    168170        accepted = (value > QBenchmarkGlobalData::current->walltimeMinimum);
     
    176178        iterationCount *= 2;
    177179
    178     this->result =
    179         QBenchmarkResult(QBenchmarkGlobalData::current->context, value, iterationCount);
     180    this->result = QBenchmarkResult(
     181        QBenchmarkGlobalData::current->context, value, iterationCount, metric, setByMacro);
    180182}
    181183
     
    209211QTest::QBenchmarkIterationController::~QBenchmarkIterationController()
    210212{
    211     QBenchmarkTestMethodData::current->setResult(QTest::endBenchmarkMeasurement());
     213    const qreal result = QTest::endBenchmarkMeasurement();
     214    QBenchmarkTestMethodData::current->setResult(result, QBenchmarkGlobalData::current->measurer->metricType());
    212215}
    213216
     
    260263/*! \internal
    261264*/
    262 qint64 QTest::endBenchmarkMeasurement()
     265quint64 QTest::endBenchmarkMeasurement()
    263266{
    264267    // the clock is ticking before the line below, don't add code here.
     
    266269}
    267270
    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*/
     288void QTest::setBenchmarkResult(qreal result, QTest::QBenchmarkMetric metric)
     289{
     290    QBenchmarkTestMethodData::current->setResult(result, metric, false);
    284291}
    285292
     
    299306}
    300307
    301 
    302308QT_END_NAMESPACE
    303 
Note: See TracChangeset for help on using the changeset viewer.