calloc - Work around gcc-8 bug (2).
[dragonfly.git] / test / sysperf / lockmgr2.c
blob435486d841eb073b8977efe564be5bb6348f3c6a
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 close(open("/tmp/lockmgr2.test", O_RDWR|O_CREAT, 0666));
31 start_timing();
32 while (stop_timing(0, NULL) == 0) {
33 fd = open("/tmp/lockmgr2.test", O_RDONLY, 0666);
34 assert(fd >= 0);
35 fstat(fd, &st);
36 close(fd);
37 ++count;
39 max = count;
40 close(fd);
42 if (ac > 1)
43 n = strtol(av[1], NULL, 0);
44 else
45 n = 1;
47 start_timing();
48 for (i = 0; i < n; ++i) {
49 asprintf(&path, "/tmp/lockmgr.test");
50 close(open(path, O_RDWR|O_CREAT, 0666));
51 if (fork() == 0) {
52 for (count = 0; count < max; ++count) {
53 fd = open(path, O_RDONLY, 0666);
54 assert(fd >= 0);
55 fstat(fd, &st);
56 close(fd);
58 _exit(0);
61 while (wait3(&status, 0, NULL) >= 0 || errno == EINTR)
63 stop_timing(max * n, "lockmgr2");
65 return(0);