Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * contrôle du temps avec library chrono ... C++ A.Villanueva
- */
- #include <iostream>
- #include <chrono>
- using namespace std;
- #define TEMPS_REF 4
- //
- bool chronometre( std::chrono::time_point<std::chrono::system_clock> t1,
- std::chrono::time_point<std::chrono::system_clock> t0,
- std::chrono::duration<double> ref){
- std::chrono::duration<double> segundos = t1 - t0;
- if (segundos > ref){ return true;}
- return false;
- }
- //temps écoulé
- void tempsEcoule( std::chrono::time_point<std::chrono::system_clock> t1,
- std::chrono::time_point<std::chrono::system_clock> t0){
- std::chrono::duration<double> segundos = t1 - t0;
- cout << "temps écoulé : " << segundos.count() << endl;
- }
- int main (){
- std::chrono::duration<double> t_ref(TEMPS_REF);
- std::chrono::time_point<std::chrono::system_clock> t0, t1,ctrl;
- t0= std::chrono::system_clock::now();
- while (true){
- t1= std::chrono::system_clock::now();//heure actuelle
- tempsEcoule(t1,t0);//DEBUG analyse du temps écoulé
- //Le programme se termine lorsqu'il atteint le temps t_ref
- if (chronometre(t1,t0,t_ref)){return (0);}
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement