3 * cc -I/usr/local/include -o time-test time-test.c -L/usr/local/lib -levent
13 #include <sys/types.h>
15 #ifdef HAVE_SYS_TIME_H
33 struct event
*ev
[NEVENT
];
39 return (int)(rand() * n
);
41 return (int)(random() % n
);
46 time_cb(int fd
, short event
, void *arg
)
53 if (called
< 10*NEVENT
) {
54 for (i
= 0; i
< 10; i
++) {
57 tv
.tv_usec
= rand_int(50000);
59 evtimer_add(ev
[j
], &tv
);
67 main (int argc
, char **argv
)
72 /* Initalize the event library */
75 for (i
= 0; i
< NEVENT
; i
++) {
76 ev
[i
] = malloc(sizeof(struct event
));
78 /* Initalize one event */
79 evtimer_set(ev
[i
], time_cb
, ev
[i
]);
81 tv
.tv_usec
= rand_int(50000);
82 evtimer_add(ev
[i
], &tv
);
87 return (called
< NEVENT
);