home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / HDX_BACK / HDX302.ST / SPEED.BAK < prev    next >
Encoding:
Text File  |  2001-02-09  |  2.8 KB  |  141 lines

  1. /* speed.c */
  2.  
  3. /* test the speet of the hard disk by read from the hard disk. */
  4.  
  5. #include "obdefs.h"
  6. #include "gemdefs.h"
  7. #include "osbind.h"
  8.  
  9.  
  10. main(argc, argv)
  11. int argc;
  12. char *argv[];
  13.  
  14. {
  15.  
  16.     char *buf;
  17.     int dev;
  18.     long sizleft, nummb; 
  19.     long start, readsiz, dirsect;
  20.     long bufsiz = 250;    /* the max sectors for the hread() */
  21.     unsigned int time1, time2;
  22.  
  23.     if (argc != 3)    {
  24.         printf("Usage: speed #Mb unit#\n");
  25.         return;
  26.     }
  27.     if ((nummb = ((long)isint(argv[1]) * 2048)) < 0)    {
  28.         printf("The input must be integers.\n");
  29.         return;
  30.     }
  31.     if ((dev = isint(argv[2])) < 0)    {
  32.         printf("The input must be integers.\n");
  33.         return;
  34.     }
  35.  
  36.     if ((buf = (char *) Malloc(bufsiz*512)) <= 0) {
  37.         printf("no system memory\n");
  38.         return;
  39.     }
  40.     start = 0;
  41.     printf("%s %d %s", "The sequential reading time for", atoi(argv[1]),
  42.                     "Mb is: "); 
  43.     time1 = Tgettime();        /* get the system time */
  44.     sizleft = nummb;
  45.     while (sizleft)    {
  46.         if (sizleft > bufsiz)    {
  47.             readsiz = bufsiz;
  48.         } else {
  49.             readsiz = sizleft;
  50.         }
  51.         if (rdsects(dev, (int)readsiz, buf, start))    {
  52.             printf("read error.\n");
  53.             goto cln;
  54.         }
  55.         sizleft -= readsiz;
  56.         start += readsiz;
  57.     }
  58.     time2 = Tgettime();        /* get the system time */
  59.     conver(time1, time2);
  60.  
  61.  
  62.     sizleft = nummb;
  63.     start = 0;
  64.     dirsect = 50;
  65.     printf("%s %d %s", "The imitated real system reading time for", 
  66.                         atoi(argv[1]), "Mb is: "); 
  67.     time1 = Tgettime();        /* get the system time */
  68.     while (sizleft)    {
  69.         if (sizleft > bufsiz)    {
  70.             readsiz = bufsiz;
  71.         } else {
  72.             readsiz = sizleft;
  73.         }
  74.         if (rdsects(dev, (int)dirsect, buf, dirsect))    {
  75.             printf("read error.\n");
  76.             goto cln;
  77.         }
  78.         if (rdsects(dev, (int)readsiz, buf, start))    {
  79.             printf("read error.\n");
  80.             goto cln;
  81.         }
  82.         sizleft -= readsiz;
  83.         start += readsiz;
  84.         dirsect -= 2;
  85.         if (!dirsect) dirsect = 50;
  86.     }
  87.     time2 = Tgettime();        /* get the system time */
  88.     conver(time1, time2);
  89. cln:
  90.     Mfree((long)buf);
  91.  
  92. }
  93.  
  94.  
  95.  
  96. conver(time1, time2)
  97.  
  98. unsigned int time1, time2;
  99.  
  100. {
  101.  
  102.     int seconds1, minutes1;
  103.     int seconds2, minutes2, result;
  104.     long hours1, hours2, totsec1, totsec2;
  105.     char mins[3], secs[3];
  106.  
  107.     seconds1 = (time1 & 0x001F) << 1;    /* bits 0:4*/
  108.     minutes1 = (time1 >> 5) & 0x3F;        /* bits 5:10 */
  109.     hours1   = (time1 >> 11) & 0x1F;        /* bits 11:15 */
  110.  
  111.     totsec1 = hours1 * 3600 + minutes1 * 60 + seconds1;
  112.  
  113.     seconds2 = (time2 & 0x001F) << 1;    /* bits 0:4*/
  114.     minutes2 = (time2 >> 5) & 0x3F;        /* bits 5:10 */
  115.     hours2   = (time2 >> 11) & 0x1F;        /* bits 11:15 */
  116.  
  117.     totsec2 = hours2 * 3600 + minutes2 * 60 + seconds2;
  118.     result = totsec2 - totsec1;
  119.  
  120.     printf("%d %s\n", result, "seconds.");
  121. }
  122.  
  123.  
  124. isint(input)
  125. char *input;
  126. {
  127.  
  128.     char *string;
  129.  
  130.     string = input;
  131.     while (*string)    {
  132.         if (*string < '0' || *string > '9')
  133.             return 0;
  134.         string++;
  135.     }
  136.     return(atoi(input));
  137.  
  138. }
  139.  
  140.  
  141.