Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/time.h>
- typedef struct {
- struct timeval startTime;
- struct timeval endTime;
- } Timer;
- Timer timer;
- void startTime();
- void stopTime();
- void elapsedTime();
- void startTime() {
- printf("Avvio Timer.\n");
- gettimeofday(&(timer.startTime), NULL);
- }
- void stopTime() {
- printf("Fermo Timer.\n");
- gettimeofday(&(timer.endTime), NULL);
- }
- void elapsedTime() {
- float elapseTime = (float) ((timer.endTime.tv_sec - timer.startTime.tv_sec) \
- + (timer.endTime.tv_usec - timer.startTime.tv_usec)/1.0e6);
- printf("Tempo trascorso: %4.2f Sec.\n",elapseTime);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement