4 # include <sys/types.h>
6 # include <sys/socket.h>
8 # include <netinet/in.h>
17 struct timeval time_before,time_after;
19 if( gettimeofday(&time_before,NULL) ){
20 perror("gettimeofday:");
26 if( gettimeofday(&time_after ,NULL) ){
27 perror("gettimeofday:");
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;
36 printf("%d-th operation took %d ms\n",i,diff);
41 /* printf("time now %d s %d us\n",time_after.tv_sec,time_after.tv_usec);
45 time_before = time_after;