home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 June / PCWorld_2001-06_cd.bin / Software / Vyzkuste / bench12 / BENCH.PAS < prev    next >
Pascal/Delphi Source File  |  1999-04-14  |  2KB  |  84 lines

  1. {$A+,B-,D-,E-,F-,G+,I-,L-,N-,O-,P-,Q-,R-,S-,T-,V-,X+,Y-}
  2. {$M 65520,0,0}
  3. uses dos;
  4. const bsize=32768;
  5. var
  6.  b:array[1..bsize] of byte;
  7.  s1,s2:string;
  8.  f1:file;
  9.  rep:word;
  10.  bnum,blen,btim:longint;
  11.  d2:longint;
  12.  d:searchrec;
  13.  i:longint;
  14. label y,x;
  15.  
  16. procedure error(s:string);
  17. begin
  18.  writeln(#10#13+s);
  19.  halt;
  20. end;
  21.  
  22. function gtime:word;assembler;
  23. asm
  24.  mov ax,0
  25.  int 1ah
  26.  mov ax,dx
  27. end;
  28.  
  29. var tmv:integer;
  30. begin
  31.  filemode:=0;
  32.  writeln('Benchmark disku v1.2 by Martin Petricek');
  33.  Writeln(' Syntaxe je BENCH <soubor k testu> [pocet opakovani]');
  34.  if paramcount=0 then s2:='*.*'else s2:=paramstr(1);
  35.  s1:=paramstr(2);
  36.  if paramcount>1 then val(s1,rep,tmv) else rep:=1;
  37.  if tmv<>0 then rep:=1;
  38.  Writeln('Pocet opakovani: ',rep);
  39.  bnum:=0;
  40.  blen:=0;
  41.  btim:=0;
  42.  FindFirst(s2,$3f,D);
  43.  while DosError = 0 do
  44.  begin
  45.  if d.attr=$10 then goto y;
  46.  s1:=d.name;
  47.  i:=gtime;
  48. for tmv:=1 to rep do
  49. begin
  50.  Write('Ctu: '+s1);
  51.  assign(f1,s1);
  52.  reset(f1,1);
  53.  if ioresult <> 0 then error('Nelze otevrit "'+s1+'"!');
  54.  d2:=filesize(f1);
  55.  write(', delka: ',d2);
  56.  inc(blen,d2);
  57.  inc(bnum);
  58. x:
  59.  if d2< bsize then
  60.   begin
  61.    blockread(f1,b,d2);
  62.    if ioresult <>0 then error('Chyba pri cteni!');
  63.   end
  64.  else
  65.   begin
  66.    d2:=d2-bsize;
  67.    blockread(f1,b,bsize);
  68.    if ioresult <>0 then error('Chyba pri cteni!');
  69.    goto x;
  70.  end;
  71.  close(f1);
  72.  writeln;
  73. end;
  74.  btim:=btim+gtime-i;
  75.  y:
  76.  FindNext(D);
  77.  end;
  78.  if bnum=0 then error('Zadny soubor nenalezen!');
  79.  Writeln('Celkovy pocet prectenych souboru:',bnum);
  80.  Writeln('Celkova velikost vsech souboru:',blen,' b');
  81.  Writeln('Cas na precteni vsech souboru:',btim /18.2:7:2,' s');
  82.  if btim <>0 then Writeln('Rychlost disku:',blen/(btim /0.0182):5:1,' KB/s')
  83.          else Writeln('Rychlost disku: Nemeritelna - Zkuste vetsi soubor')
  84. end.