4 * Objetive: Test the time it takes for select to run.
6 * Description: This tests creates a number of udp connections and performs
7 * a select call waiting on them for reading with timeout of 0.
8 * This is done 10,000 thousands of times and then the average time it takes
14 #include <sys/types.h>
17 #include <sys/select.h>
18 #include <sys/asynchio.h>
22 #include <net/netlib.h>
31 struct timeval timeout
;
32 time_t start_time
, end_time
;
36 for (i
= 0; i
< NUMBER
; i
++) {
37 fd
[i
] = open("/dev/tty", O_RDWR
);
39 fprintf(stderr
, "Error opening tty %d\n", i
);
42 FD_SET(fd
[i
], &fds_write
);
45 printf("Select will send 1 msg to terminal and %d to inet: \n", NUMBER
);
48 /* get initial time */
49 start_time
= time(NULL
);
50 for (i
= 0; i
< 32000; i
++) {
51 select(NUMBER
+ 4, NULL
, &fds_write
, NULL
, &timeout
);
54 end_time
= time(NULL
);
55 printf("The select call took on average: %f\n", (float)(end_time
- start_time
) / 32000.0);
56 for (i
= 0; i
< NUMBER
; i
++) {