本文整理汇总了C++中QElapsedTimer::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ QElapsedTimer::isValid方法的具体用法?C++ QElapsedTimer::isValid怎么用?C++ QElapsedTimer::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QElapsedTimer
的用法示例。
在下文中一共展示了QElapsedTimer::isValid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onStateChartCycle
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();
}
}
示例2: validity
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());
}
示例3: gitProgressCB
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;
}
示例4: monotonicallyIncreasingTime
double monotonicallyIncreasingTime()
{
ASSERT(QElapsedTimer::isMonotonic());
static QElapsedTimer timer;
if (!timer.isValid())
timer.start();
return timer.nsecsElapsed() / 1.0e9;
}
示例5: currentTimeForEvent
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;
}
示例6: runTest
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 ¤tCommit : 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.");
}