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

1.1     ! root        1: /*
        !             2:  * IPC benchmark,
        !             3:  * write to self using pipes.
        !             4:  */
        !             5: 
        !             6: main(argc, argv)
        !             7:        char *argv[];
        !             8: {
        !             9:        char buf[512];
        !            10:        int fd[2], msgsize;
        !            11:        register int i, iter;
        !            12: 
        !            13:        if (argc < 3) {
        !            14:                printf("usage: %s iterations message-size\n", argv[0]);
        !            15:                exit(1);
        !            16:        }
        !            17:        argc--, argv++;
        !            18:        iter = atoi(*argv);
        !            19:        argc--, argv++;
        !            20:        msgsize = atoi(*argv);
        !            21:        if (msgsize > sizeof (buf) || msgsize <= 0) {
        !            22:                printf("%s: Bad message size.\n", *argv);
        !            23:                exit(2);
        !            24:        }
        !            25:        if (pipe(fd) < 0) {
        !            26:                perror("pipe");
        !            27:                exit(3);
        !            28:        }
        !            29:        for (i = 0; i < iter; i++) {
        !            30:                write(fd[1], buf, msgsize);
        !            31:                read(fd[0], buf, msgsize);
        !            32:        }
        !            33: }

unix.superglobalmegacorp.com

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