5.6.3 : Le fichier timer.h
Bien entendu, nous aurons besoin d'un chronomètre pour effectuer nos tests de performances.Développons le timer.h :
Prennons en compte les inclusions multiples :
1 2 |
#ifndef __TIMER_H__ #define __TIMER_H__ |
Utilsons le chronomètre de la std
1 |
#include <chrono>
|
Définssions quelques types que nous utiliserons pour notre horloge :
1 2 3 |
typedef std::chrono::steady_clock HiPeClock; typedef std::chrono::nanoseconds NanoSecs; typedef std::chrono::time_point<std::chrono::steady_clock> HiPeTime; |
Définissons le prototype de notre fonction :
1 2 3 |
HiPeTime phoenix_getTime();
#endif
|
Le fichier timer.h complet :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
/*************************************** Auteur : Pierre Aubert Mail : pierre.aubert@lapp.in2p3.fr Licence : CeCILL-C ****************************************/ #ifndef __TIMER_H__ #define __TIMER_H__ #include <chrono> typedef std::chrono::steady_clock HiPeClock; typedef std::chrono::nanoseconds NanoSecs; typedef std::chrono::time_point<std::chrono::steady_clock> HiPeTime; HiPeTime phoenix_getTime(); #endif |
Le fichier timer.h est disponible ici.