dimanche 22 décembre 2019

Get execution time without taking into account the not scheduled time

I'm trying to measure the time in a loop in this way on Linux:

void Timer::run() {
    while ( isRunning() ) {
        auto start = std::chrono::steady_clock::now();
        doSomething();
        auto stop = std::chrono::steady_clock::now();
        auto waitingTime = tick - (stop - start);
        waitFor(waitingTime);
    }
}

It works but if while my program is executing doSomething() I stop the process using kill -STOP and then I resume the process using kill -CONT I can see that waitingTime includes the time where the program was suspended. Is it possible to retrieve only the real execution time?

Aucun commentaire:

Enregistrer un commentaire