-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathTimer.cpp
More file actions
43 lines (34 loc) · 1.16 KB
/
Timer.cpp
File metadata and controls
43 lines (34 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* -------------------------------------------------
_ _ ___
__ _| |_ _ _(_)___/ __| __ __ _ _ _ _ _ ___ _ _
/ _` | _| '_| / -_)__ \/ _/ _` | ' \| ' \/ -_) '_|
\__, |\__|_| |_\___|___/\__\__,_|_||_|_||_\___|_|
|___/
gtrieScanner: quick discovery of network motifs
Released under Artistic License 2.0
(see README and LICENSE)
Pedro Ribeiro - CRACS & INESC-TEC, DCC/FCUP
----------------------------------------------------
Timers for time measurement
Last Update: 11/02/2012
---------------------------------------------------- */
#include "Timer.h"
// Static variables
struct timeval Timer::cstart[MAX_TIMERS];
struct timeval Timer::cend[MAX_TIMERS];
// Stop the clock of a timer
void Timer::start(int n) {
if (n>=0 && n<MAX_TIMERS)
gettimeofday(&cstart[n], NULL);
}
// Elapsed time of a timer
void Timer::stop(int n) {
if (n>=0 && n<MAX_TIMERS)
gettimeofday(&cend[n], NULL);
}
double Timer::elapsed(int n) {
if (n>=0 && n<MAX_TIMERS)
return (cend[n].tv_sec - cstart[n].tv_sec) + (double)(cend[n].tv_usec - cstart[n].tv_usec)/1000000.0;
else
return 0;
}