home *** CD-ROM | disk | FTP | other *** search
/ PC to Maximum / PC-na-maximum.bin / DriveSpeed / SRC / DRSP / RESULTS.CPP < prev   
Encoding:
C/C++ Source or Header  |  2000-06-04  |  6.1 KB  |  210 lines

  1. /*
  2.  *  DRSP - DriveSpeed, version 3.10 (GPL FREEWARE)
  3.  *  Copyleft (l) Stanislav Sokolov, May 1998 and onwards.
  4.  *
  5.  *  This program is subject to GNU General Public License ver. 2 of June 1991
  6.  *  and any later version.
  7.  *
  8.  *  You may use this source with your programs, provided
  9.  *  due credits are given.
  10.  *
  11.  *  Contact the author by e-mail: stanislavs@hotmail.com
  12.  *
  13.  *  Internet:  http://members.tripod.com/~stanislavs/prog/prog.htm
  14.  */
  15.  
  16. #include "D:\TC\MY\DRSP\DRSP.H"
  17. #include "D:\TC\UTILS\USER\USER.H"
  18.  
  19. //Analyze a RW process
  20. void Analyze(TestData TD, float WriteSpd, float ReadSpd, float FAS){
  21.     FILE *Handle;
  22.     GetTxt *Txt = new GetTxt;  //A class from my user library
  23.     char FName[MAX_PATH];
  24.     char Append, Comment[70] = {'\0'};
  25.     struct time curTime;
  26.     struct date curDate;
  27.     float WriteKB, WriteMB, ReadKB, ReadMB;
  28.  
  29.     signal(SIGFPE, Trap);    //Install floating point error handler
  30.  
  31.     WriteKB = (TD.TestSize * 1024.0) / WriteSpd;
  32.     WriteMB = TD.TestSize / (WriteSpd / 60.0);
  33.  
  34.     ReadKB = (TD.TestSize * 1024.0) / ReadSpd;
  35.     ReadMB = TD.TestSize / (ReadSpd / 60.0);
  36.  
  37.     if(fError) Abort(0, NULL, "Overflow in a variable.", EX_MATH_ERR);
  38.     if(Txt == NULL) Abort(0, NULL, "Out of memory in Analyze()", EX_NO_MEM);
  39.  
  40.     gettime(&curTime);
  41.     getdate(&curDate);
  42.  
  43.     printf(DBL_LINE);
  44.     printf("Drive:\t\t\t\t  %c:\n", TD.Drive);
  45.  
  46.     printf("Test size in MB:\t\t%#6.2f\n", TD.TestSize);
  47.     printf("Number of turns:\t\t%3i\n\n", TD.Turns);
  48.  
  49.     printf("Average write speed in KB/Sec:\t%#20.12f\n", WriteKB);
  50.     printf("Average write speed in MB/Min:\t%#20.12f\n\n", WriteMB);
  51.  
  52.     printf("Average read speed in KB/Sec:\t%#20.12f\n", ReadKB);
  53.     printf("Average read speed in MB/Min:\t%#20.12f\n\n", ReadMB);
  54.  
  55.     printf("FAS in operations/Sec:\t\t  %#9.3f", FAS);
  56.     printf(DBL_LINE);
  57.  
  58.     //Open the log-file
  59.     if((Handle = OpenLog(TD, FName)) == NULL)
  60.         Abort(0, NULL, "Error opening log-file.", EX_NO_LOG);
  61.  
  62.     //Suppress any user interaction in batch mode and log the results
  63.     if(!TD.Batch){
  64.         printf("\nDo you want to append these results to an ASCII log-file\n"
  65.                "%s? (Y/N) ", strupr(FName));
  66.  
  67.         Append = Ask("");
  68.     }else{
  69.         Append = 'Y';
  70.     }
  71.  
  72.     if(Append == 'Y' || Append == 13){
  73.         if(!TD.Batch){
  74.             printf("\n\nPlease enter your optional comments to this test on the line below.\n"
  75.                    "Comments: ");
  76.  
  77.             Txt->InText(Comment, 69, wherey(), wherex(), 69);
  78.         }
  79.  
  80.         printf("\n%s\n%s\n", L1, L2);
  81.         printf(DISK_STAT, TD.Drive, TD.TestSize, TD.Turns, WriteKB, WriteMB, ReadKB, ReadMB);
  82.         printf("%s\n", L3);
  83.         printf(FAS_STAT, curDate.da_day, curDate.da_mon, curDate.da_year, curTime.ti_hour, curTime.ti_min, FAS);
  84.         printf("%s\n", L4);
  85.  
  86.         fprintf(Handle, "\n%s%s\n", "Comments: ", Comment);
  87.         fprintf(Handle, "%s\n%s\n", L1, L2);
  88.         fprintf(Handle, DISK_STAT, TD.Drive, TD.TestSize, TD.Turns, WriteKB, WriteMB, ReadKB, ReadMB);
  89.         fprintf(Handle, "%s\n", L3);
  90.         fprintf(Handle, FAS_STAT, curDate.da_day, curDate.da_mon, curDate.da_year, curTime.ti_hour, curTime.ti_min, FAS);
  91.         fprintf(Handle, "%s\n", L4);
  92.     }
  93.  
  94.     if(fclose(Handle) == EOF)
  95.         Abort(0, NULL, "Error closing log-file.", EX_NO_LOG);
  96.  
  97.     delete Txt;
  98.     printf("\n\n");
  99. }
  100.  
  101.  
  102. //Analyze a RO process
  103. void Analyze(TestData TD, float ReadSpd){
  104.     FILE *Handle;
  105.     GetTxt *Txt = new GetTxt;  //A class from my user library
  106.     char FName[MAX_PATH];
  107.     char Append, Comment[70] = {'\0'};
  108.     struct time curTime;
  109.     struct date curDate;
  110.     float ReadKB, ReadMB;
  111.  
  112.     signal(SIGFPE, Trap);    //Install floating point error handler
  113.  
  114.     //TestSize is in megabytes
  115.     ReadKB = (TD.TestSize * 1024.0) / ReadSpd;
  116.     ReadMB = TD.TestSize / (ReadSpd / 60.0);
  117.  
  118.     if(fError) Abort(0, NULL, "\nOverflow in a variable.", EX_MATH_ERR);
  119.     if(Txt == NULL) Abort(0, NULL, "Out of memory in Analyze()", EX_NO_MEM);
  120.  
  121.  
  122.  
  123.     gettime(&curTime);
  124.     getdate(&curDate);
  125.  
  126.     printf(DBL_LINE);
  127.     printf("Drive:\t\t\t\t  %c:\n", TD.Drive);
  128.  
  129.     printf("Test size in MB:\t\t%#6.2f\n", TD.TestSize);
  130.     printf("Number of turns:\t\t%3i\n\n", TD.Turns);
  131.  
  132.     printf("Average read speed in KB/Sec:\t%#20.12f\n", ReadKB);
  133.     printf("Average read speed in MB/Min:\t%#20.12f", ReadMB);
  134.  
  135.     printf(DBL_LINE);
  136.  
  137.     //Open the log-file
  138.     if((Handle = OpenLog(TD, FName)) == NULL)
  139.         Abort(0, NULL, "Error opening log-file.", EX_NO_LOG);
  140.  
  141.     //Suppress any user interaction in batch mode and log the results
  142.     if(!TD.Batch){
  143.         printf("\nDo you want to append these results to an ASCII log-file\n"
  144.                "%s? (Y/N) ", strupr(FName));
  145.  
  146.         Append = Ask("");
  147.     }else{
  148.         Append = 'Y';
  149.     }
  150.  
  151.     if(Append == 'Y' || Append == 13){
  152.         if(!TD.Batch){
  153.             printf("\n\nPlease enter your optional comments to this test on the line below.\n"
  154.                    "Comments: ");
  155.  
  156.             Txt->InText(Comment, 69, wherey(), wherex(), 69);
  157.         }
  158.  
  159.         printf("\n%s\n%s\n", L1, L2);
  160.         printf(DISK_STAT, TD.Drive, TD.TestSize, TD.Turns, 0.0, 0.0, ReadKB, ReadMB);
  161.         printf("%s\n", L3);
  162.         printf(NO_FAS, curDate.da_day, curDate.da_mon, curDate.da_year, curTime.ti_hour, curTime.ti_min);
  163.         printf("%s\n", L4);
  164.  
  165.         fprintf(Handle, "\n%s%s\n", "Comments: ", Comment);
  166.         fprintf(Handle, "%s\n%s\n", L1, L2);
  167.         fprintf(Handle, DISK_STAT, TD.Drive, TD.TestSize, TD.Turns, 0.0, 0.0, ReadKB, ReadMB);
  168.         fprintf(Handle, "%s\n", L3);
  169.         fprintf(Handle, NO_FAS, curDate.da_day, curDate.da_mon, curDate.da_year, curTime.ti_hour, curTime.ti_min);
  170.         fprintf(Handle, "%s\n", L4);
  171.     }
  172.  
  173.     if(fclose(Handle) == EOF)
  174.         Abort(0, NULL, "Error closing log-file.", EX_NO_LOG);
  175.  
  176.     delete Txt;
  177.     printf("\n\n");
  178. }
  179.  
  180.  
  181. FILE *OpenLog(TestData TD, char *FName){
  182.     FILE *Handle;
  183.     char Path[MAX_PATH];
  184.  
  185.     //Initialize and extract program's start-up path
  186.     for(int i=0; i<=79; i++)
  187.         Path[i] = '\0';
  188.  
  189.     FindPath(Path);
  190.  
  191.     //Make log-file path and name
  192.     if(TD.LogFile == NULL){  //Use default
  193.         strcpy(FName, Path);
  194.         strcat(FName, "DRSP.LOG");
  195.     }else{                     //User wants another file!
  196.         strcpy(FName, TD.LogFile);
  197.     }
  198.  
  199.     //Attempt opening the file
  200.     Handle = fopen(FName, "at");
  201.     if(Handle == NULL){ //Something is wrong
  202.         if(TD.LogFile != NULL){  //Try default - perhaps user gave wrong filename!
  203.             strcpy(FName, Path);
  204.             strcat(FName, "DRSP.LOG");
  205.             Handle = fopen(FName, "at");
  206.         }
  207.     }
  208.  
  209.     return Handle;
  210. }