-
Notifications
You must be signed in to change notification settings - Fork 0
/
timer.c
45 lines (34 loc) · 848 Bytes
/
timer.c
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
#include "cse356header.h"
main(int argc, char *argv[])
{
pid_t forkpid;
timeval start, stop;
forkpid = fork();
gettimeofday(&start, NULL);
if(forkpid == 0) {
execl("./MyCopy", "MyCopy", argv[1], argv[2], NULL);
exit(0);
}
wait(NULL);
gettimeofday(&stop, NULL);
printf("MyCopy took %lu\n", stop.tv_usec - start.tv_usec);
forkpid = fork();
gettimeofday(&start, NULL);
if(forkpid == 0) {
execl("./ForkCopy", "ForkCopy", argv[1], argv[2], NULL);
exit(0);
}
wait(NULL);
gettimeofday(&stop, NULL);
printf("ForkCopy took %lu\n", stop.tv_usec - start.tv_usec);
forkpid = fork();
gettimeofday(&start, NULL);
if(forkpid == 0) {
execl("./PipeCopy", "PipeCopy", argv[1], argv[2], NULL);
exit(0);
}
wait(NULL);
gettimeofday(&stop, NULL);
printf("PipeCopy took %lu\n", stop.tv_usec - start.tv_usec);
exit(0);
}