Annotation of 43BSDReno/sys/nfs/TEST/unix-tests/special/nstat.c, revision 1.1.1.1

1.1       root        1: /*     @(#)nstat.c     1.2 90/01/03 NFS Rev 2 Testsuite
                      2:  *     1.3 Lachman ONC Test Suite source
                      3:  *
                      4:  * Stat a file n times
                      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:        register int count;
                     24:        register int i;
                     25:        struct stat statb;
                     26: 
                     27:        if (argc != 2) {
                     28:                fprintf(stderr, "usage: %s count\n", argv[0]);
                     29:                exit(1);
                     30:        }
                     31: 
                     32:        count = atoi(argv[1]);
                     33:        gettimeofday(&stim, 0);
                     34:        for (i=0; i<count; i++) {
                     35:                stat(argv[0], &statb);
                     36:                stats++;
                     37:        }
                     38:        gettimeofday(&etim, 0);
                     39:        elapsed = (float) (etim.tv_sec - stim.tv_sec) +
                     40:            (float)(etim.tv_usec - stim.tv_usec) / 1000000.0;
                     41:        if (elapsed == 0.0) {
                     42:                fprintf(stdout, "%d calls 0.0 seconds\n", count);
                     43:        } else {
                     44:                fprintf(stdout,
                     45:                    "%d calls %.2f seconds %.2f calls/sec %.2f msec/call\n",
                     46:                    count, elapsed, (float)count / elapsed,
                     47:                    1000.0 * elapsed / (float)count);
                     48:        }
                     49:        exit(0);
                     50: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.