Added upstream from http://ftp.icm.edu.pl/pub/loglan/
[loglan.git] / sources / int / net / ip / t.c
1 # include       <stdio.h>
2 # include       <string.h>
3 # include       <stdlib.h>
4 # include       <sys/types.h>
5 # include       <signal.h>
6 # include       <sys/socket.h>
7 # include       <sys/time.h>
8 # include       <netinet/in.h>
9 # include       <netdb.h>
10 # include       <errno.h>
11
12
13 int main(){
14
15    int i=0;
16    long diff;
17    struct timeval time_before,time_after;
18
19    if( gettimeofday(&time_before,NULL) ){
20       perror("gettimeofday:");
21       exit(1);
22    }
23
24    for(;;i++){
25
26       if( gettimeofday(&time_after ,NULL) ){
27          perror("gettimeofday:");
28          exit(1);
29       }
30
31       diff  = (time_after.tv_sec - time_before.tv_sec)*1000;
32       diff -= time_before.tv_usec/1000;
33       diff += time_after .tv_usec/1000;
34
35       if( diff < 0 ){
36          printf("%d-th operation took %d ms\n",i,diff);
37          fflush(stdout);
38          i=0;
39       }
40
41 /*      printf("time now %d s %d us\n",time_after.tv_sec,time_after.tv_usec);
42 */
43       fflush(stdout);
44
45       time_before = time_after;
46
47    }
48
49    return 0;
50 }
51