/**
 * Takes argc,argv along with one of the benchmark functions defined above.
 * Will loop along all skp files and perform measurments.
 *
 * Returns a SkScalar representing CPU time taken during benchmark.
 * As a side effect, it spits the timer result to stdout.
 * Will return -1.0 on error.
 */
static bool benchmark_loop(
        int argc,
        char **argv,
        const BenchmarkControl& benchControl,
        SkTArray<Histogram>& histogram) {
    static const SkString timeFormat("%f");
    TimerData timerData(argc - 1);
    for (int index = 1; index < argc; ++index) {
        BenchTimer timer;
        SkString path(argv[index]);
        SkAutoTUnref<SkPicture> pic(pic_from_path(path.c_str()));
        if (NULL == pic) {
            SkDebugf("Couldn't create picture. Ignoring path: %s\n", path.c_str());
            continue;
        }
        benchControl.fFunction(benchControl.fType, benchControl.fTileSize, path, pic, &timer);
        SkAssertResult(timerData.appendTimes(&timer));

        histogram[index - 1].fPath = path;
        histogram[index - 1].fCpuTime = SkDoubleToScalar(timer.fCpu);
    }

    const SkString timerResult = timerData.getResult(
            /*doubleFormat = */ timeFormat.c_str(),
            /*result = */ TimerData::kAvg_Result,
            /*configName = */ benchControl.fName.c_str(),
            /*timerFlags = */ TimerData::kCpu_Flag);

    const char findStr[] = "= ";
    int pos = timerResult.find(findStr);
    if (-1 == pos) {
        SkDebugf("Unexpected output from TimerData::getResult(...). Unable to parse.");
        return false;
    }

    SkScalar cpuTime = SkDoubleToScalar(atof(timerResult.c_str() + pos + sizeof(findStr) - 1));
    if (cpuTime == 0) {  // atof returns 0.0 on error.
        SkDebugf("Unable to read value from timer result.\n");
        return false;
    }
    return true;
}
bool ZmdUpdaterCore::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: catalogData((const QValueList<QVariant>&)*((const QValueList<QVariant>*)static_QUType_ptr.get(_o+1)),(const QVariant&)static_QUType_QVariant.get(_o+2)); break;
    case 1: identityData((const QValueList<QVariant>&)*((const QValueList<QVariant>*)static_QUType_ptr.get(_o+1)),(const QVariant&)static_QUType_QVariant.get(_o+2)); break;
    case 2: catalogSubData((const QValueList<QVariant>&)*((const QValueList<QVariant>*)static_QUType_ptr.get(_o+1)),(const QVariant&)static_QUType_QVariant.get(_o+2)); break;
    case 3: serviceData((const QValueList<QVariant>&)*((const QValueList<QVariant>*)static_QUType_ptr.get(_o+1)),(const QVariant&)static_QUType_QVariant.get(_o+2)); break;
    case 4: updateData((const QValueList<QVariant>&)*((const QValueList<QVariant>*)static_QUType_ptr.get(_o+1)),(const QVariant&)static_QUType_QVariant.get(_o+2)); break;
    case 5: patchData((const QValueList<QVariant>&)*((const QValueList<QVariant>*)static_QUType_ptr.get(_o+1)),(const QVariant&)static_QUType_QVariant.get(_o+2)); break;
    case 6: lockData((const QValueList<QVariant>&)*((const QValueList<QVariant>*)static_QUType_ptr.get(_o+1)),(const QVariant&)static_QUType_QVariant.get(_o+2)); break;
    case 7: infoData((const QValueList<QVariant>&)*((const QValueList<QVariant>*)static_QUType_ptr.get(_o+1)),(const QVariant&)static_QUType_QVariant.get(_o+2)); break;
    case 8: faultData((int)static_QUType_int.get(_o+1),(const QString&)static_QUType_QString.get(_o+2),(const QVariant&)static_QUType_QVariant.get(_o+3)); break;
    case 9: transactData((const QValueList<QVariant>&)*((const QValueList<QVariant>*)static_QUType_ptr.get(_o+1)),(const QVariant&)static_QUType_QVariant.get(_o+2)); break;
    case 10: timerSlot(); break;
    case 11: timerData((const QValueList<QVariant>&)*((const QValueList<QVariant>*)static_QUType_ptr.get(_o+1)),(const QVariant&)static_QUType_QVariant.get(_o+2)); break;
    case 12: abortData((const QValueList<QVariant>&)*((const QValueList<QVariant>*)static_QUType_ptr.get(_o+1)),(const QVariant&)static_QUType_QVariant.get(_o+2)); break;
    default:
	return QObject::qt_invoke( _id, _o );
    }
    return TRUE;
}
Ejemplo n.º 3
0
Message::Message(QColor base,unsigned hang_time,
		 QWidget *parent,const char *name)
  : QWidget(parent,name)
{
  msg_base_color=base;
  msg_hang_time=hang_time;
  msg_hanging=false;
  msg_send_lines=2;

  //
  // The Send Box
  //
  msg_send_box=new SendMsgTextEdit(this);
  connect(msg_send_box,SIGNAL(messageSent()),this,SLOT(sendData()));

  //
  // The Receive Box
  //
  msg_rcv_box=new MsgTextEdit(this);
  connect(msg_rcv_box,SIGNAL(doubleClicked()),
	  this,SLOT(doubleClickedData()));
  connect(msg_rcv_box,SIGNAL(nicknameChanged(const QString &)),
	  this,SLOT(nicknameChangedData(const QString &)));
  connect(msg_rcv_box,SIGNAL(clearClicked()),this,SLOT(clearClickedData()));

  //
  // The Backdrop
  //
  //  msg_backdrop_label=new QLabel(this);
  //DrawBackdrop();
  //msg_backdrop_label->hide();

  //
  // The Hang Timer
  //
  msg_hang_timer=new QTimer(this);
  connect(msg_hang_timer,SIGNAL(timeout()),this,SLOT(timerData()));
}
void PictureBenchmark::run(SkPicture* pict) {
    SkASSERT(pict);
    if (NULL == pict) {
        return;
    }

    SkASSERT(fRenderer != NULL);
    if (NULL == fRenderer) {
        return;
    }

    fRenderer->init(pict);

    // We throw this away to remove first time effects (such as paging in this program)
    fRenderer->setup();
    fRenderer->render(NULL);
    fRenderer->resetState(true);

    bool usingGpu = false;
#if SK_SUPPORT_GPU
    usingGpu = fRenderer->isUsingGpuDevice();
#endif

    uint32_t timerTypes = fTimerTypes;
    if (!usingGpu) {
        timerTypes &= ~TimerData::kGpu_Flag;
    }

    SkString timeFormat;
    if (TimerData::kPerIter_Result == fTimerResult) {
        timeFormat = fRenderer->getPerIterTimeFormat();
    } else {
        timeFormat = fRenderer->getNormalTimeFormat();
    }

    if (fTimeIndividualTiles) {
        TiledPictureRenderer* tiledRenderer = fRenderer->getTiledRenderer();
        SkASSERT(tiledRenderer && tiledRenderer->supportsTimingIndividualTiles());
        if (NULL == tiledRenderer || !tiledRenderer->supportsTimingIndividualTiles()) {
            return;
        }
        int xTiles, yTiles;
        if (!tiledRenderer->tileDimensions(xTiles, yTiles)) {
            return;
        }

        // Insert a newline so that each tile is reported on its own line (separate from the line
        // that describes the skp being run).
        this->logProgress("\n");

        int x, y;
        while (tiledRenderer->nextTile(x, y)) {
            // There are two timers, which will behave slightly differently:
            // 1) longRunningTimer, along with perTileTimerData, will time how long it takes to draw
            // one tile fRepeats times, and take the average. As such, it will not respect thea
            // logPerIter or printMin options, since it does not know the time per iteration. It
            // will also be unable to call flush() for each tile.
            // The goal of this timer is to make up for a system timer that is not precise enough to
            // measure the small amount of time it takes to draw one tile once.
            //
            // 2) perTileTimer, along with perTileTimerData, will record each run separately, and
            // then take the average. As such, it supports logPerIter and printMin options.
            //
            // Although "legal", having two gpu timers running at the same time
            // seems to cause problems (i.e., INVALID_OPERATIONs) on several
            // platforms. To work around this, we disable the gpu timer on the
            // long running timer.
            SkAutoTDelete<BenchTimer> longRunningTimer(this->setupTimer());
            TimerData longRunningTimerData(1);
            SkAutoTDelete<BenchTimer> perTileTimer(this->setupTimer(false));
            TimerData perTileTimerData(fRepeats);
            longRunningTimer->start();
            for (int i = 0; i < fRepeats; ++i) {
                perTileTimer->start();
                tiledRenderer->drawCurrentTile();
                perTileTimer->truncatedEnd();
                tiledRenderer->resetState(false);
                perTileTimer->end();
                SkAssertResult(perTileTimerData.appendTimes(perTileTimer.get()));
            }
            longRunningTimer->truncatedEnd();
            tiledRenderer->resetState(true);
            longRunningTimer->end();
            SkAssertResult(longRunningTimerData.appendTimes(longRunningTimer.get()));

            SkString configName = tiledRenderer->getConfigName();
            configName.appendf(": tile [%i,%i] out of [%i,%i]", x, y, xTiles, yTiles);

            SkString result = perTileTimerData.getResult(timeFormat.c_str(), fTimerResult,
                                                         configName.c_str(), timerTypes);
            result.append("\n");

// TODO(borenet): Turn off per-iteration tile time reporting for now.  Avoiding logging the time
// for every iteration for each tile cuts down on data file size by a significant amount. Re-enable
// this once we're loading the bench data directly into a data store and are no longer generating
// SVG graphs.
#if 0
            this->logProgress(result.c_str());
#endif

            configName.append(" <averaged>");
            SkString longRunningResult = longRunningTimerData.getResult(
                tiledRenderer->getNormalTimeFormat().c_str(),
                TimerData::kAvg_Result,
                configName.c_str(), timerTypes, fRepeats);
            longRunningResult.append("\n");
            this->logProgress(longRunningResult.c_str());
        }
    } else {
        SkAutoTDelete<BenchTimer> timer(this->setupTimer());
        TimerData timerData(fRepeats);
        for (int i = 0; i < fRepeats; ++i) {
            fRenderer->setup();

            timer->start();
            fRenderer->render(NULL);
            timer->truncatedEnd();

            // Finishes gl context
            fRenderer->resetState(true);
            timer->end();

            SkAssertResult(timerData.appendTimes(timer.get()));
        }

        SkString configName = fRenderer->getConfigName();

        SkString result = timerData.getResult(timeFormat.c_str(),
                                              fTimerResult,
                                              configName.c_str(),
                                              timerTypes);
        result.append("\n");
        this->logProgress(result.c_str());
    }

    fRenderer->end();
}