-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.c
More file actions
29 lines (24 loc) · 834 Bytes
/
Copy pathbenchmark.c
File metadata and controls
29 lines (24 loc) · 834 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
#include "benchmark.h"
void benchmark(int argc, char *argv[], int num_of_calls, char *system_call_command)
{
clock_t start;
char *envs[3];
double results[3];
envs[0] = "vfork + execvp";
start = clock();
for (int i = 0; i < num_of_calls; i++)
execute(argc, argv);
results[0] = ((double)(clock() - start)) / CLOCKS_PER_SEC;
envs[1] = "fork + execvp";
start = clock();
for (int i = 0; i < num_of_calls; i++)
execute2(argc, argv);
results[1] = ((double)(clock() - start)) / CLOCKS_PER_SEC;
envs[2] = "system call";
start = clock();
for (int i = 0; i < num_of_calls; i++)
system(system_call_command);
results[2] = ((double)(clock() - start)) / CLOCKS_PER_SEC;
for (int i = 0; i < 3; i++)
printf("time: %f [%s]\n", results[i], envs[i]);
}