home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / byteunix.lzh / byte.1 / pipe.c < prev    next >
C/C++ Source or Header  |  1990-05-11  |  1KB  |  42 lines

  1. /*******************************************************************************
  2.  *  The BYTE UNIX Benchmarks - Release 2
  3.  *          Module: pipe.c   SID: 2.4 4/17/90 16:45:35
  4.  *          
  5.  *******************************************************************************
  6.  * Bug reports, patches, comments, suggestions should be sent to:
  7.  *
  8.  *    Ben Smith or Rick Grehan at BYTE Magazine
  9.  *    bensmith@bixpb.UUCP    rick_g@bixpb.UUCP
  10.  *
  11.  *******************************************************************************
  12.  *  Modification Log:
  13.  *  $Header: pipe.c,v 3.5 87/06/22 14:32:36 kjmcdonell Beta $
  14.  *
  15.  ******************************************************************************/
  16. char SCCSid[] = "@(#) @(#)pipe.c:2.4 -- 4/17/90 16:45:35";
  17. /*
  18.  *  pipe  -- test single process pipe throughput (no context switching)
  19.  *
  20.  */
  21.  
  22. main(argc, argv)
  23. int    argc;
  24. char    *argv[];
  25. {
  26.     char    buf[512];
  27.     int    iter = 2048;    /* 1M byte */
  28.     int    pvec[2];
  29.  
  30.     pipe(pvec);
  31.     close(0); dup(pvec[0]); close(pvec[0]);
  32.     close(1); dup(pvec[1]); close(pvec[1]);
  33.  
  34.     while (iter-- > 0) {
  35.         if (write(1, buf, sizeof(buf)) != sizeof(buf))
  36.             perror("write failed");
  37.         if (read(0, buf, sizeof(buf)) != sizeof(buf))
  38.             perror("read failed");
  39.     }
  40.     exit(0);
  41. }
  42.