home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / fj / os / 386bsd / 318 < prev    next >
Encoding:
Text File  |  1993-01-24  |  2.5 KB  |  78 lines

  1. Path: sparky!uunet!ccut!news.u-tokyo.ac.jp!yayoi!tansei1!mhiroshi
  2. From: mhiroshi@tansei.cc.u-tokyo.ac.jp (H. Murakami)
  3. Newsgroups: fj.os.386bsd
  4. Subject: A Disk I/O transfer rate measurement program.
  5. Message-ID: <3979@tansei1.tansei.cc.u-tokyo.ac.jp>
  6. Date: 24 Jan 93 00:13:38 GMT
  7. Sender: news@tansei.cc.u-tokyo.ac.jp
  8. Distribution: fj
  9. Organization: Hokkaido Univ. However I am subject to tansei for JUNET.
  10. Lines: 66
  11.  
  12. To: fj.os.386bsd
  13. Subject: Disk I/O transfer rate measurement program.
  14.  
  15. /****************************************************
  16.  *                                                  *
  17.  *       Disk I/O transfer rate measurement test    *
  18.  *  by sequentially reading the raw device disk.    *
  19.  *                                                  *
  20.  *  NOTE: No write to disk is attempted.            *
  21.  *                                                  *
  22.  *    Usage: modify the definition of DEVICE below  *
  23.  *  suitably for your environment.                  *
  24.  *  Then compile and run on the non-busy machine.   *
  25.  *                                                  *
  26.  ***************************************************/
  27.  
  28. #define DEVICE "/dev/rwd0c"  /* Raw device to be tested. */
  29.  
  30.  
  31.  
  32. #include <stdio.h>
  33. #include <sys/file.h>
  34. #include <sys/types.h>
  35. #include <sys/times.h>
  36.  
  37. #define NB (512*200)
  38. static char     buf[NB];
  39.  
  40. #define AHZ 60 /* different system may be different. */
  41. #define MEGA (1024*1024)
  42.  
  43.  
  44. main()
  45. {
  46.       int             d, nbytes, nread;
  47.       clock_t         t1, t2;
  48.       double          t;
  49.       static struct tms tm1, tm2;
  50.       int             nsect, size;
  51.       int             from=10, step=10, until=100; /* modify as you like.*/
  52.  
  53.       for (nsect=from; nsect<=until; nsect+=step) {
  54.  
  55.             size = 512 * nsect;
  56.             nread = 0;
  57.             if ((d=open(DEVICE, O_RDONLY, 0444)) <= 0) {
  58.                   fprintf(stderr, "Error at open.\n");
  59.                   exit(1); }
  60.             if (size > NB) {
  61.                   fprintf(stderr, "Program error. size > NB.\n");
  62.                   exit(1); }
  63.             t1 = times(&tm1);
  64.             while (1) {
  65.                   nbytes = read(d, buf, size);
  66.                   if (nbytes <= 0) break;
  67.                   nread += nbytes;
  68.             }
  69.             t2 = times(&tm2);
  70.             t = (double) (t2 - t1) / AHZ;
  71.             printf("Device: %s\n", DEVICE);
  72.             printf("%3u: %6.2lf MB read. %6.2lf Sec. %6.2lf MB/Sec.\n",
  73.                    nsect, (double) nread / MEGA, t, nread / t / MEGA);
  74.             close(d);
  75.       }
  76. }
  77. /* THE END. */
  78.