/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "cdtst.h"

int main()
{
   int i,j;
   time_t t1,t2;
   FILE *fp;
   char data[CHUNK],data2[CHUNK];
   memset(data2,'A',sizeof(data));
   for(j=0;j<NREP;j++) {
      fp = fopen("CDTST.DAT","rb");
      t1 = time(NULL);
      for(i=0;i<NRECS;i++) {
         fread(data,sizeof(data),1,fp);
         if(memcmp(data,data2,sizeof(data))!=0) {
            printf("Corrupt data read\n");
            exit(EXIT_FAILURE);
         }
      }
      t2 = time(NULL);
      printf("Speed = %5.2f MB/s (= %2dX speed)\n",(1.0*NMB)/(t2-t1),(int)(((1.0*NMB)/(t2-t1))/0.15+0.5));
      fclose(fp);
   }
   exit(EXIT_SUCCESS);
}

