gcc80: Partially implement TOOLCHAIN_CHECKING.
[dragonfly.git] / test / sysperf / lockmgr3.c
blobedbded9e2cb8b1b8d5ac707c2ed81d67974e16ac
1 /*
2 * varsym..c
4 * varsym [threads]
6 * tests shared lock using varsym_get()
7 */
9 #include "blib.h"
10 #include <sys/file.h>
11 #include <assert.h>
13 int
14 main(int ac, char **av)
16 long long count = 0;
17 long long max;
18 char c;
19 int n;
20 int i;
21 int j;
22 int fd;
23 int status;
24 char *path;
25 char buf[256];
26 struct stat st;
28 printf("timing standard fstat() syscall\n");
30 fd = open("/tmp/lockmgr3.test", O_RDWR|O_CREAT, 0666);
31 assert(fd >= 0);
32 start_timing();
33 while (stop_timing(0, NULL) == 0) {
34 fstat(fd, &st);
35 fstat(fd, &st);
36 fstat(fd, &st);
37 fstat(fd, &st);
38 ++count;
40 max = count * 4;
41 close(fd);
43 if (ac > 1)
44 n = strtol(av[1], NULL, 0);
45 else
46 n = 1;
48 start_timing();
49 for (i = 0; i < n; ++i) {
50 if (fork() == 0) {
51 asprintf(&path, "/tmp/lockmgr.test");
52 fd = open(path, O_RDWR|O_CREAT, 0666);
53 assert(fd >= 0);
54 for (count = 0; count < max; ++count) {
55 fstat(fd, &st);
56 fstat(fd, &st);
57 fstat(fd, &st);
58 fstat(fd, &st);
60 _exit(0);
63 while (wait3(&status, 0, NULL) >= 0 || errno == EINTR)
65 stop_timing(max * n * 4, "lockmgr3");
67 return(0);