void DefaultStateChartDriver::onStateChartCycle()
{

    //void
    m_sc->runCycle();
    if (m_sc->getDefaultSCI()->isRaised_heartbeat())
    {
    	static QElapsedTimer timer;
    	if (timer.isValid())
    		qDebug() << "heartbeat :" << timer.elapsed() << "/ 1000";
        timer.restart();
    }
    if (m_sc->getDefaultSCI()->isRaised_footstomp())
    {
    	static QElapsedTimer timer;
    	if (timer.isValid())
    		qDebug() << "footstomp :"  << timer.elapsed() << "/300";
        timer.restart();
    }
    if (m_sc->getDefaultSCI()->isRaised_fingertap())
    {
    	static QElapsedTimer timer;
    	if (timer.isValid())
    		qDebug() << "fingertap :"  << timer.elapsed() << "/ 215";
        timer.restart();
    }

    if (m_sc->getDefaultSCI()->isRaised_done())
    {
        qDebug() << "done";
        QCoreApplication::quit();
    }
}
Esempio n. 2
0
void tst_QElapsedTimer::validity()
{
    QElapsedTimer t;

    QVERIFY(!t.isValid()); // non-POD now, it should always start invalid

    t.start();
    QVERIFY(t.isValid());

    t.invalidate();
    QVERIFY(!t.isValid());
}
Esempio n. 3
0
void tst_QElapsedTimer::validity()
{
    QElapsedTimer t;

    t.invalidate();
    QVERIFY(!t.isValid());

    t.start();
    QVERIFY(t.isValid());

    t.invalidate();
    QVERIFY(!t.isValid());
}
Esempio n. 4
0
extern "C" int gitProgressCB(bool reset, const char *text)
{
	static QElapsedTimer timer;
	static qint64 lastTime;
	static QString lastText;
	static QMLManager *self;
	static int lastPercent;

	if (!self)
		self = QMLManager::instance();

	if (!timer.isValid() || reset) {
		timer.restart();
		lastTime = 0;
		lastPercent = 0;
		lastText.clear();
	}
	if (self) {
		qint64 elapsed = timer.elapsed();
		// don't show the same status twice in 200ms
		if (lastText == text && elapsed - lastTime < 200)
			return 0;
		self->loadDiveProgress(++lastPercent);
		QString logText = QString::number(elapsed / 1000.0, 'f', 1) + " / " + QString::number((elapsed - lastTime) / 1000.0, 'f', 3) +
				  QString(" : git %1 (%2)").arg(lastPercent).arg(text);
		self->appendTextToLog(logText);
		qDebug() << logText;
		if (elapsed - lastTime > 500)
			qApp->processEvents();
		lastTime = elapsed;
	}
	// return 0 so that we don't end the download
	return 0;
}
double monotonicallyIncreasingTime()
{
    ASSERT(QElapsedTimer::isMonotonic());
    static QElapsedTimer timer;
    if (!timer.isValid())
        timer.start();
    return timer.nsecsElapsed() / 1.0e9;
}
Esempio n. 6
0
static inline double currentTimeForEvent(const QInputEvent* event)
{
    Q_ASSERT(event);

    if (event->timestamp())
        return static_cast<double>(event->timestamp()) / 1000;

    static QElapsedTimer timer;
    if (!timer.isValid())
        timer.start();
    return static_cast<double>(timer.elapsed()) / 1000;
}
Esempio n. 7
0
void FuzzyTester::runTest(const QString &profile, const QString &startCommit,
                          int maxDurationInMinutes, int jobCount, bool log)
{
    m_profile = profile;
    m_jobCount = jobCount;
    m_log = log;

    runGit(QStringList() << "rev-parse" << "HEAD", &m_headCommit);
    qDebug("HEAD is %s", qPrintable(m_headCommit));

    qDebug("Trying to find a buildable commit to start with...");
    const QString workingStartCommit = findWorkingStartCommit(startCommit);
    qDebug("Found buildable start commit %s.", qPrintable(workingStartCommit));
    QStringList allCommits = findAllCommits(workingStartCommit);
    qDebug("The test set comprises all %d commits between the start commit and HEAD.",
           allCommits.size());

    // Shuffle the initial sequence. Otherwise all invocations of the tool with the same start
    // commit would try the same sequence of commits.
    std::srand(std::time(nullptr));
    std::random_shuffle(allCommits.begin(), allCommits.end());

    quint64 run = 0;
    QStringList buildSequence(workingStartCommit);
    QElapsedTimer timer;
    const qint64 maxDurationInMillis = maxDurationInMinutes * 60 * 1000;
    if (maxDurationInMillis != 0)
        timer.start();

    bool timerHasExpired = false;
    while (std::next_permutation(allCommits.begin(), allCommits.end()) && !timerHasExpired) {
        qDebug("Testing permutation %llu...", ++run);
        const auto &allCommitsImmutable = allCommits;
        for (const QString &currentCommit : allCommitsImmutable) {
           if (timer.isValid() && timer.hasExpired(maxDurationInMillis)) {
               timerHasExpired = true;
               break;
           }

            m_currentCommit = currentCommit;
            buildSequence << currentCommit;
            checkoutCommit(currentCommit);
            qDebug("Testing incremental build #%d (%s)", buildSequence.size() - 1,
                   qPrintable(currentCommit));

            // Doing "resolve" and "build" separately introduces additional possibilities
            // for errors, as information from change tracking has to be serialized correctly.
            QString qbsError;
            m_currentActivity = resolveIncrementalActivity();
            bool success = runQbs(defaultBuildDir(), QLatin1String("resolve"), &qbsError);
            if (success) {
                m_currentActivity = buildIncrementalActivity();
                success = runQbs(defaultBuildDir(), QLatin1String("build"), &qbsError);
            }
            m_currentActivity = buildFromScratchActivity();
            if (success) {
                if (!doCleanBuild(&qbsError)) {
                    QString message = "An incremental build succeeded "
                                      "with a commit for which a clean build failed.";
                    if (!m_log) {
                        message += QString::fromLatin1("\nThe qbs error message "
                                "for the clean build was: '%1'").arg(qbsError);
                    }
                    throwIncrementalBuildError(message, buildSequence);
                }
            } else {
                qDebug("Incremental build failed. Checking whether clean build works...");
                if (doCleanBuild()) {
                    QString message = "An incremental build failed "
                                      "with a commit for which a clean build succeeded.";
                    if (!m_log) {
                        message += QString::fromLatin1("\nThe qbs error message for "
                                "the incremental build was: '%1'").arg(qbsError);
                    }
                    throwIncrementalBuildError(message, buildSequence);
                } else {
                    qDebug("Clean build also fails. Continuing.");
                }
            }
        }
    }

    if (timerHasExpired)
        qDebug("Maximum duration reached.");
    else
        qDebug("All possible permutations were tried.");
}