4 * $DragonFly: src/test/sysperf/exec1.c,v 1.2 2004/04/14 17:59:45 dillon Exp $
8 #include <sys/resource.h>
11 #include <machine/atomic.h>
22 if ((elm
= strrchr(Av0
, '/')) == NULL
)
27 if ((pid
= vfork()) == 0) {
28 execl(Av0
, elm
, "dummy", NULL
);
36 while (waitpid(pid
, &status
, 0) != pid
)
38 if (WEXITSTATUS(status
)) {
39 fprintf(stderr
, "execl in child failed\n");
46 main(int ac
, char **av
)
55 countr
= mmap(NULL
, 4096, PROT_READ
|PROT_WRITE
, MAP_ANON
|MAP_SHARED
, -1, 0);
58 if (ac
== 2 && strcmp(av
[1], "dummy") == 0)
62 ncpus
= strtol(av
[1], NULL
, 0);
66 while (stop_timing(0, NULL
) == 0) {
67 for (i
= 0; i
< 100; ++i
)
71 count
*= 5; /* 5 second run */
73 for (n
= 0; n
< ncpus
; ++n
) {
76 while (get_timing() < 5000000) {
81 atomic_add_long(countr
, count
);
85 while (wait3(&status
, 0, NULL
) >= 0 || errno
== EINTR
)
88 stop_timing(*countr
, "execl static program:");
90 stop_timing(*countr
, "execl dynamic program:");