|
|
1.1 ! root 1: /* @(#)stat2.c 1.2 90/01/03 NFS Rev 2 Testsuite ! 2: * 1.3 Lachman ONC Test Suite source ! 3: * ! 4: * create a bunch of files and stat them repeatedly ! 5: */ ! 6: #include <stdio.h> ! 7: #include <sys/types.h> ! 8: #include <sys/stat.h> ! 9: #ifdef SVR3 ! 10: #include <sys/fs/nfs/time.h> ! 11: #else ! 12: #include <sys/time.h> ! 13: #endif ! 14: ! 15: int stats = 0; ! 16: ! 17: main(argc, argv) ! 18: int argc; ! 19: char *argv[]; ! 20: { ! 21: struct timeval stim, etim; ! 22: float elapsed; ! 23: int files, count; ! 24: register int i, j; ! 25: char name[256]; ! 26: struct stat statb; ! 27: ! 28: if (argc != 4) { ! 29: fprintf(stderr, "usage: %s dir files count\n", argv[0]); ! 30: exit(1); ! 31: } ! 32: ! 33: if (mkdir(argv[1], 0777) < 0) { ! 34: perror(argv[1]); ! 35: } ! 36: chdir(argv[1]); ! 37: files = atoi(argv[2]); ! 38: count = atoi(argv[3]); ! 39: for (i=0; i<files; i++) { ! 40: sprintf(name, "%d", i); ! 41: close(creat(name, 0666)); ! 42: } ! 43: ! 44: gettimeofday(&stim, 0); ! 45: for (i=0; i<count; i++) { ! 46: for (j=0; j<files; j++) { ! 47: sprintf(name, "%d", i); ! 48: stat(name, &statb); ! 49: stats++; ! 50: } ! 51: } ! 52: gettimeofday(&etim, 0); ! 53: elapsed = (float) (etim.tv_sec - stim.tv_sec) + ! 54: (float)(etim.tv_usec - stim.tv_usec) / 1000000.0; ! 55: fprintf(stdout, "%d calls in %f seconds (%f calls/sec)\n", ! 56: stats, elapsed, (float)stats / elapsed); ! 57: exit(0); ! 58: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.