-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.h
More file actions
44 lines (35 loc) · 749 Bytes
/
timer.h
File metadata and controls
44 lines (35 loc) · 749 Bytes
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
#include <stdio.h>
#include <stdlib.h>
//#include <stdbool.h>
//#include <string.h> /* memset */
#include <assert.h> /* assert */
#include <sys/time.h> /* gettimeofday */
//#include <sys/types.h>
//#include <errno.h>
#include <unistd.h> //sleep
size_t checkpoint(void)
{
struct timeval tv;
int rc;
rc = gettimeofday(&tv, NULL);
assert(rc == 0); /* XXX: provide more correct solution */
//what the FUCK????
return 1000000*tv.tv_sec + tv.tv_usec;
}
void report(size_t elapsed)
{
// printf("time=%5.5f\n", ((float)elapsed)/tm);
//mks
//how from size_t do float
printf("time=%5.5f\n", ((float)elapsed));
}
/*
int main()
{
size_t start = checkpoint();
sleep(2);
size_t finish = checkpoint();
report(finish - start);
return 0;
}
*/