#include #include #include #include #include long tesame, wszystkie; int c; void sigalrm (int signo) { // printf ("%d: tesame=%ld wszystkie=%ld\n", c, tesame, wszystkie); if (c) { // pomijamy pierwszy wynik - moze nie byc wlasciwy printf ("%ld roznych gettimeofday() per sec\n", wszystkie - tesame); } tesame = wszystkie = 0; if (c++ > 9) { exit (0); } alarm (1); } int main () { struct timeval tvnew, tvold; tesame = wszystkie = c = 0; if (signal (SIGALRM, sigalrm) == SIG_ERR) { perror ("signal"); exit (-1); } alarm (1); for (;;) { gettimeofday (&tvold, NULL); gettimeofday (&tvnew, NULL); wszystkie++; if ((tvnew.tv_sec == tvold.tv_sec) && (tvnew.tv_usec == tvold.tv_usec)) { tesame++; } } return 0; }