Upgrade libressl. 1/2
[dragonfly.git] / test / sysperf / lockmgr3.c
1 /*
2  * varsym..c
3  *
4  * varsym [threads]
5  *
6  * tests shared lock using varsym_get()
7  */
8
9 #include "blib.h"
10 #include <sys/file.h>
11 #include <assert.h>
12
13 int
14 main(int ac, char **av)
15 {
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;
27
28         printf("timing standard fstat() syscall\n");
29
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;
39         }
40         max = count * 4;
41         close(fd);
42
43         if (ac > 1)
44                 n = strtol(av[1], NULL, 0);
45         else
46                 n = 1;
47
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);
59                         }
60                         _exit(0);
61                 }
62         }
63         while (wait3(&status, 0, NULL) >= 0 || errno == EINTR)
64                 ;
65         stop_timing(max * n * 4, "lockmgr3");
66
67         return(0);
68 }