Annotation of Net2/tests/benchmarks/seqpage.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Sequential page access benchmark.
        !             3:  */
        !             4: #include <sys/vadvise.h>
        !             5: 
        !             6: char   *valloc();
        !             7: 
        !             8: main(argc, argv)
        !             9:        char *argv[];
        !            10: {
        !            11:        register i, niter;
        !            12:        register char *pf, *lastpage;
        !            13:        int npages = 4096, pagesize, vflag = 0;
        !            14:        char *pages, *name;
        !            15: 
        !            16:        name = argv[0];
        !            17:        argc--, argv++;
        !            18: again:
        !            19:        if (argc < 1) {
        !            20: usage:
        !            21:                printf("usage: %s [ -v ] [ -k #Kb ] niter\n", name);
        !            22:                exit(1);
        !            23:        }
        !            24:        if (strcmp(*argv, "-k") == 0) {
        !            25:                argc--, argv++;
        !            26:                if (argc < 1)
        !            27:                        goto usage;
        !            28:                npages = atoi(*argv);
        !            29:                if (npages <= 0) {
        !            30:                        printf("%s: Bad virtual memory size.\n", *argv);
        !            31:                        exit(2);
        !            32:                }
        !            33:                argc--, argv++;
        !            34:                goto again;
        !            35:        }
        !            36:        if (strcmp(*argv, "-v") == 0) {
        !            37:                argc--, argv++;
        !            38:                vflag++;
        !            39:                goto again;
        !            40:        }
        !            41:        niter = atoi(*argv);
        !            42:        pagesize = getpagesize();
        !            43:        npages /= pagesize / 1024;
        !            44:        pages = valloc(npages, pagesize);
        !            45:        if (pages == (char *)0) {
        !            46:                printf("Can't allocate %d pages (%2.1f megabytes).\n",
        !            47:                    npages, (npages * pagesize) / (1024. * 1024.));
        !            48:                exit(3);
        !            49:        }
        !            50:        if (pagesize != 1024)
        !            51:                printf("Pagesize %dKb\n", pagesize / 1024);
        !            52:        lastpage = pages + (npages * pagesize);
        !            53:        if (vflag)
        !            54:                vadvise(VA_SEQL);
        !            55:        for (i = 0; i < niter; i++)
        !            56:                for (pf = pages; pf < lastpage; pf += pagesize)
        !            57:                        *pf = 1;
        !            58: }

unix.superglobalmegacorp.com

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