本文整理汇总了C++中QElapsedTimer类的典型用法代码示例。如果您正苦于以下问题:C++ QElapsedTimer类的具体用法?C++ QElapsedTimer怎么用?C++ QElapsedTimer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QElapsedTimer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, const char* argv[]) {
QElapsedTimer startupTime;
startupTime.start();
int exitCode;
{
QSettings::setDefaultFormat(QSettings::IniFormat);
Application app(argc, const_cast<char**>(argv), startupTime);
QTranslator translator;
translator.load("interface_en");
app.installTranslator(&translator);
exitCode = app.exec();
}
return exitCode;
}
示例2: saveHistogram
void MainWindow::saveHistogram(QStringList listImages)
{
QDir dir;
int size = listImages.length();
this->edit->append("Saving histograms");
QElapsedTimer timer;
timer.start();
// PARALLEL CODE
int i;
QString xml;
QString xml_path;
QString image;
QString image_path;
Histogram *h;
QList<Histogram*> list_hist;
//#pragma omp parallel firstprivate(list_hist) shared(list_images)
#pragma omp parallel shared(list_images, list_hist)
{
#pragma omp for private(i, xml, xml_path, image, image_path, h)
for(i = 0; i < size; i++)
{
xml = "hist_"+ QString("%1").arg(this->imageID + (i+1), 6, 10, QChar('0')) + ".xml";
xml_path = dir.absolutePath() + "/" + this->HistFolder+"/"+ xml;
image = list_images[i];
image_path = dir.absolutePath() + "/" + this->ImageFolder + "/" + image;
h = new Histogram(image.toStdString(), image_path.toStdString(), xml_path.toStdString());
list_hist.append(h);
}
//cout << "Fi de la tasca pel fil " << omp_get_thread_num() << endl;
#pragma omp barrier
}
this->list_hist = list_hist;
// END PARALLEL CODE
this->edit->append("Save complete.");
this->edit->append("Time: " + QString::number(timer.elapsed()) + "milliseconds");
cout << "End copy histograms" << endl;
}
示例3: waitForBound
bool QLlcpSocketPrivate::waitForBound(int msecs)
{
if (m_state == QLlcpSocket::BoundState)
return true;
QElapsedTimer timer;
timer.start();
while (m_state != QLlcpSocket::BoundState && (msecs == -1 || timer.elapsed() < msecs)) {
if (!m_socketRequestor->waitForDBusSignal(qMax(msecs - timer.elapsed(), qint64(0))))
return false;
}
// Possibly not needed.
QCoreApplication::sendPostedEvents(this, QEvent::MetaCall);
return m_state == QLlcpSocket::BoundState;
}
示例4: Q_D
/*!
Process pending events that match \a flags for a maximum of \a
maxTime milliseconds, or until there are no more events to
process, whichever is shorter.
This function is especially useful if you have a long running
operation and want to show its progress without allowing user
input, i.e. by using the \l ExcludeUserInputEvents flag.
\bold{Notes:}
\list
\o This function does not process events continuously; it
returns after all available events are processed.
\o Specifying the \l WaitForMoreEvents flag makes no sense
and will be ignored.
\endlist
*/
void QEventLoop::processEvents(ProcessEventsFlags flags, int maxTime)
{
Q_D(QEventLoop);
if (!d->threadData->eventDispatcher)
return;
QElapsedTimer start;
start.start();
if (flags & DeferredDeletion)
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
while (processEvents(flags & ~WaitForMoreEvents)) {
if (start.elapsed() > maxTime)
break;
if (flags & DeferredDeletion)
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
}
}
示例5: emit
void OTF2ExportFunctor::exportTrace(Trace * trace, const QString& path,
const QString& filename)
{
std::cout << "Exporting " << filename.toStdString().c_str() << std::endl;
QElapsedTimer traceTimer;
qint64 traceElapsed;
traceTimer.start();
OTF2Exporter * exporter = new OTF2Exporter(trace);
exporter->exportTrace(path, filename);
traceElapsed = traceTimer.nsecsElapsed();
RavelUtils::gu_printTime(traceElapsed, "Total export time: ");
emit(done());
}
示例6: GOMNE_fixed_q
void MainWindow::GOMNE_fixed_q()
{
QElapsedTimer tgomne;
tgomne.start();
RobotTraj();
Init();
par->isinside=0;
par->nb_beacon = ui->BeaconSpinBox->value();
//cout<<"q"<<par->q<<endl;
ui->EpsilonSpinBox->setValue(1);
for (uint i=0;i<100;i++){
par->err[i] = 0.2;
}
ui->ErrSpinBox_1->setValue(par->err[0]);
ui->ErrSpinBox_2->setValue(par->err[1]);
ui->ErrSpinBox_3->setValue(par->err[2]);
ui->ErrSpinBox_4->setValue(par->err[3]);
ui->ErrSpinBox_5->setValue(par->err[4]);
//epsilon<0.01 check is just to stop the algorithm when it doesnt find a solution to not freeze the window
while(par->isinside!=1 && par->epsilon_sivia>0.01){
if(par->in_perhaps==0){
par->q--;
ui->InterSpinBox->setValue(par->q);
Sivia sivia(*R,par);
//cout<<"q--"<<endl;
}
if(par->in_perhaps==1){
par->epsilon_sivia/=2;
Sivia sivia(*R,par);
ui->EpsilonSpinBox->setValue(par->epsilon_sivia);
}
}
SLAM(step);
repaint();
if (timeinfo){
QString mess = "Execution time : ";
mess.append(QString::number(tgomne.elapsed()));mess.append(" ms");
QMessageBox::information(this,"Info",mess);
}
ui->InterSpinBox->setValue(par->q);
}
示例7: on_action_write_triggered
void MainWindow::on_action_write_triggered()
{
QString xlsFile = QFileDialog::getExistingDirectory(this);
if(xlsFile.isEmpty())
return;
xlsFile += "/excelRWByCztr1988.xls";
QElapsedTimer timer;
timer.start();
if(m_xls.isNull())
m_xls.reset(new ExcelBase);
m_xls->create(xlsFile);
qDebug()<<"create cost:"<<timer.elapsed()<<"ms";timer.restart();
QList< QList<QVariant> > m_datas;
for(int i=0;i<1000;++i)
{
QList<QVariant> rows;
for(int j=0;j<100;++j)
{
rows.append(i*j);
}
m_datas.append(rows);
}
m_xls->setCurrentSheet(1);
timer.restart();
m_xls->writeCurrentSheet(m_datas);
qDebug()<<"write cost:"<<timer.elapsed()<<"ms";timer.restart();
m_xls->save();
}
示例8: block
QNetworkReply* AdBlockManager::block(const QNetworkRequest &request)
{
#ifdef ADBLOCK_DEBUG
QElapsedTimer timer;
timer.start();
#endif
const QString urlString = request.url().toEncoded().toLower();
const QString urlDomain = request.url().host().toLower();
const QString urlScheme = request.url().scheme().toLower();
if (!isEnabled() || !canRunOnScheme(urlScheme)) {
return 0;
}
foreach (AdBlockSubscription* subscription, m_subscriptions) {
const AdBlockRule* blockedRule = subscription->match(request, urlDomain, urlString);
if (blockedRule) {
QVariant v = request.attribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 100));
WebPage* webPage = static_cast<WebPage*>(v.value<void*>());
if (WebPage::isPointerSafeToUse(webPage)) {
if (!canBeBlocked(webPage->url())) {
return 0;
}
webPage->addAdBlockRule(blockedRule, request.url());
}
AdBlockBlockedNetworkReply* reply = new AdBlockBlockedNetworkReply(subscription, blockedRule, this);
reply->setRequest(request);
#ifdef ADBLOCK_DEBUG
qDebug() << "BLOCKED: " << timer.elapsed() << blockedRule->filter() << request.url();
#endif
return reply;
}
}
#ifdef ADBLOCK_DEBUG
qDebug() << timer.elapsed() << request.url();
#endif
return 0;
}
示例9: _readDtmData
static QByteArray _readDtmData( QgsRasterDataProvider *provider, const QgsRectangle &extent, int res )
{
QElapsedTimer t;
t.start();
// TODO: use feedback object? (but GDAL currently does not support cancelation anyway)
QgsRasterBlock *block = provider->block( 1, extent, res, res );
QByteArray data;
if ( block )
{
block->convert( Qgis::Float32 ); // currently we expect just floats
data = block->data();
data.detach(); // this should make a deep copy
delete block;
}
return data;
}
示例10: decorateBatch
void decorateBatch()
{
if (m_tc.isNull())
return;
QElapsedTimer t;
t.start();
do {
m_tc = m_tc.document()->find(m_re, m_tc, QTextDocument::FindBackward);
if (m_tc.isNull())
return;
decorate(&m_tc);
} while ( t.elapsed() < 20 );
m_timerDecorate.start();
}
示例11: l
QFuture<PlaylistItemPtr> PlaylistBackend::GetPlaylistItems(int playlist) {
QMutexLocker l(db_->Mutex());
QElapsedTimer timer;
timer.start();
QList<SqlRow> rows = GetPlaylistRows(playlist);
// it's probable that we'll have a few songs associated with the
// same CUE so we're caching results of parsing CUEs
std::shared_ptr<NewSongFromQueryState> state_ptr(new NewSongFromQueryState());
QFuture<PlaylistItemPtr> test = QtConcurrent::mapped(
rows, std::bind(&PlaylistBackend::NewPlaylistItemFromQuery, this, _1,
state_ptr));
test.waitForFinished();
QTextStream out(stdout);
out << "TTIMER: " << timer.elapsed() << "\n";
return test;
}
示例12: Render
void DavaGLWidget::Render()
{
QElapsedTimer frameTimer;
frameTimer.start();
DAVA::QtLayer::Instance()->ProcessFrame();
qint64 waitUntilNextFrameMs = (qint64) minFrameTimeMs - frameTimer.elapsed();
if(waitUntilNextFrameMs <= 0)
{
// our render is too slow to reach maxFPS,
// so we can wait a minimum time
waitUntilNextFrameMs = 1;
}
QTimer::singleShot(waitUntilNextFrameMs, this, SLOT(Render()));
}
示例13: main
int main(int argc, char *argv[]){
static qint64 vTime = 0;
QElapsedTimer et;
et.start();
QApplication a(argc, argv);
game = new Game();
game->show();
vTime += et.nsecsElapsed();
qDebug() << "time elapsed for app launch:" << vTime << "ns";
return a.exec();
}
示例14: binarizacia
void Predspracovanie::on_pushButton_6_clicked()//500ppi
{
QElapsedTimer timer;
timer.start();
this->calculateOrientations(this->mat,globBlockSize);
this->adaptive_segmentation(this->mat,globBlockSize,0.161,-0.5,0.975,0.009);
mat_po_normal = this->normalisation(this->mat,20,5);
binarizacia(this->mat_po_normal);
this->calculateOrientations(this->mat_po_normal,globBlockSize);
this->gaborFilter(globBlockSize);
binarizacia(this->mat_filtrovana);
thinning(this->kostra,this->mat_filtrovana);
bitwise_not(this-> mat_filtrovana, this->mat_filtrovana);
ui->cas->setText(QString::number(timer.elapsed()) + "ms");
}
示例15: qDebug
/* Once all the average RGB values found for both sub-images and each block in the main image,
* this function finds the color difference between
*/
QStringList* PhotoMosaic::colorDifference(RGB* dirArr, int dirArrSize, RGB* mainArr, int mainArrSize, int precision) const
{
qDebug() << "in colordifference";
QStringList *list = new QStringList(); // size of i,
QElapsedTimer timer;
timer.start();
int pos = 0;
int percentageDone = 0;
int onePercent = mainArrSize / 100;
int count = onePercent;
qDebug() << onePercent;
for (int i = 0; i < mainArrSize; i = i + precision) {
// display percentage of the work is done.
if (i >= count) {
percentageDone++;
count += onePercent;
qDebug() << percentageDone;
}
//Calculate the average euclidean distances for each picture in the sub-picture directory.
//based on the precision, divide each block further by precision.
//this can theoratically increase the accuracy (as long as there are enough mosaics to choose from.
double min = 255 * precision * precision; // it should be 255 * (precision * precision)
for (int j = 0; j < dirArrSize; j = j + precision) {
double sum = 0;
for (int x = 0; x < precision; x++) {
sum += euclideanDistanceRGB(mainArr[i + x], dirArr[j + x]);
}
if (sum < min) {
min = sum;
pos = j / precision;
}
sum = 0;
}
QString picName = QString::number(pos);
list->append(picName);
}
qDebug() << "COLOR DIFFERENCE Took" << timer.elapsed() << "milliseconds";
return list;
}