Anonymní profil peter – Programujte.com
 x   TIP: Přetáhni ikonu na hlavní panel pro připnutí webu

Anonymní profil peter – Programujte.comAnonymní profil peter – Programujte.com

 

Příspěvky odeslané z IP adresy 2001:718:2601:26c:a1ee:5a...–

peter
C / C++ › qt mereni casu trvani funkci
14. 10. 2015   #205630

   

         ui->textEdit->append(QString::number(myTimer->next()));
            Sleep(100);
         ui->textEdit->append(QString::number(myTimer->next()));

// Jo opravil jsem to na float, ale stale to pise nulu
LONGLONG myMicroTimeClass::get()
float myMicroTimeClass::get()
peter
C / C++ › qt mereni casu trvani funkci
14. 10. 2015   #205629

Narazim na pro mne naprosto zahadny problem. Nejak to nepocita.
 

         float a = myTimer->get();
            Sleep(100);
//         ui->textEdit->append(QString::number(myTimer->next()));
//         ui->textEdit->append(QString::number(myTimer->get()));
//         ui->textEdit->append(QString::number(myTimer->getFreq()));
         float x = myTimer->get();
         float y = myTimer->getFreq();
         float b = x - a;
         float z = x/y;
         float c = b/y;
         ui->textEdit->append(QString::number(x));
         ui->textEdit->append(QString::number(y));
         ui->textEdit->append(QString::number(z));
         ui->textEdit->append(QString::number(b));
         ui->textEdit->append(QString::number(c));
/*
Vygeneruje
376933400966
3.76935e+11
1.43182e+07
26325.6
1.47456e+06
0.102985 - cili 100 ms, spravne
*/

Jenze kod funkce NEXT vypise nulu.
myMicroTimeClass::myMicroTimeClass()
{
    this->clock_frequency = this->getFreq();
    this->start();
}
myMicroTimeClass::~myMicroTimeClass()
{
}
float myMicroTimeClass::getFreq()
{
    QueryPerformanceFrequency(&this->freq);
    return (float)this->freq.QuadPart;
}
LONGLONG myMicroTimeClass::get()
{
    QueryPerformanceCounter(&this->time);
    return (float)this->time.QuadPart;
}
void myMicroTimeClass::start()
{
    this->time_start = this->get();
}
void myMicroTimeClass::end()
{
    this->time_end = this->get();
}
myMicroTimeClass::next()
{
    this->end();
    this->delta = this->time_end - this->time_start;
    this->delta_second = this->delta / this->clock_frequency;
    this->start();
    return (float)this->delta_second;
    // / ((float)(this->clock_frequency));
//    return (float)this->clock_frequency;
//     / this->clock_frequency.QuadPart
}

peter
C / C++ › qt mereni casu trvani funkci
14. 10. 2015   #205624

Dik. Trochu googlovani k te funkci. Nasel jsem i pekne videjko a trocha to prepsal (protoze mi to neslo uplne vlozit, ale s tim se jeste poperu). A meri to.

         LARGE_INTEGER clock_frequency;
         LARGE_INTEGER start_time;
         LARGE_INTEGER end_time;
         LARGE_INTEGER delta;
         float delta_second;

         QueryPerformanceFrequency(&clock_frequency);
         QueryPerformanceCounter(&start_time);
         Sleep(200);
         QueryPerformanceCounter(&end_time);

         delta.QuadPart = end_time.QuadPart - start_time.QuadPart;
         delta_second   = ((float)delta.QuadPart) / clock_frequency.QuadPart;
         ui->textEdit->append(QString::number(delta_second));

 

 

Hostujeme u Českého hostingu       ISSN 1801-1586       ⇡ Nahoru Webtea.cz logo © 20032024 Programujte.com
Zasadilo a pěstuje Webtea.cz, šéfredaktor Lukáš Churý