-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.h
More file actions
47 lines (41 loc) · 1.13 KB
/
timer.h
File metadata and controls
47 lines (41 loc) · 1.13 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
44
45
46
47
// Chirag Dhamange
// CSCI 551 Fall '24 Final Parallel Program
// Updated on 10/27/24
// Referenced from
// Chirag Dhamange
// CSCI 551 Fall '24 Assignment 4
// Updated on 10/27/24
// The file provides a function wrapper for getting current time
// It is provided by Peter S. Pacheco and is based on the code
// given in the book
/* File: timer.h
*
* Purpose: Define a macro that returns the number of seconds that
* have elapsed since some point in the past. The timer
* should return times with microsecond accuracy.
*
* Note: The argument passed to the GET_TIME macro should be
* a double, *not* a pointer to a double.
*
* Example:
* #include "timer.h"
* . . .
* double start, finish, elapsed;
* . . .
* GET_TIME(start);
* . . .
* Code to be timed
* . . .
* GET_TIME(finish);
* elapsed = finish - start;
* printf("The code to be timed took %e seconds\n", elapsed);
*/
#ifndef _TIMER_H_
#define _TIMER_H_
#include <sys/time.h>
#define GET_TIME(now) { \
struct timeval t; \
gettimeofday(&t, NULL); \
now = t.tv_sec + t.tv_usec/1000000.0; \
}
#endif