MFC rev 1.2:
[dragonfly.git] / test / sysperf / exec1.c
blob3a4c74a2657dec019c4340d5c144ac979635a1b3
1 /*
2 * exec1.c
4 * $DragonFly: src/test/sysperf/exec1.c,v 1.2 2004/04/14 17:59:45 dillon Exp $
5 */
7 #include "blib.h"
8 #include <sys/resource.h>
9 #include <sys/wait.h>
10 #include <sys/time.h>
12 char *Av0;
14 static
15 void
16 execltest(void)
18 pid_t pid;
19 char *elm;
21 if ((elm = strrchr(Av0, '/')) == NULL)
22 elm = Av0;
23 else
24 ++elm;
26 if ((pid = vfork()) == 0) {
27 setpriority(PRIO_PROCESS, getpid(), -20);
28 execl(Av0, elm, "dummy", NULL);
29 _exit(1);
30 } else if (pid < 0) {
31 perror("vfork");
32 exit(1);
33 } else {
34 int status;
36 while(waitpid(pid, &status, 0) != pid)
38 if (WEXITSTATUS(status)) {
39 fprintf(stderr, "execl in child failed\n");
40 exit(1);
45 int
46 main(int ac, char **av)
48 int i;
49 int count;
51 Av0 = av[0];
52 if (ac == 2)
53 exit(0);
55 count = 0;
56 start_timing();
57 while (stop_timing(0, NULL) == 0) {
58 for (i = 0; i < 100; ++i)
59 execltest();
60 count += 100;
62 count *= 5; /* 5 second run */
63 start_timing();
64 for (i = 0; i < count; ++i)
65 execltest();
66 #ifdef ISSTATIC
67 stop_timing(count, "execl static program:", count);
68 #else
69 stop_timing(count, "execl dynamic program:", count);
70 #endif
71 return(0);