#include #include #include #include #include #include int main (int argc,char **argv) { int a,b,c; FILE *f; struct timeval cs,ce; struct stat m_stat; char *mfile = "myfile.txt"; f = fopen(mfile,"r"); for(b=c=0;c<200;c++) { gettimeofday(&cs,NULL); a = fseek(f,-1,SEEK_END); gettimeofday(&ce,NULL); b += ce.tv_usec - cs.tv_usec; } printf("my avg fseek:%d\n", (b/200)); for(b=c=0;c<200;c++) { gettimeofday(&cs,NULL); a = fstat(fileno(f),&m_stat); gettimeofday(&ce,NULL); b += ce.tv_usec - cs.tv_usec; } printf("my avg fstat:%d\n", (b/200)); fclose(f); }