Changeset 31 for trunk


Ignore:
Timestamp:
Apr 30, 2016, 12:16:19 AM (9 years ago)
Author:
chronos
Message:
  • Added: TFileStreamEx experimental class to support flags O_DIRECT and O_SYNC under Linux.
Location:
trunk
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/CoolDisk.lpi

    r28 r31  
    8585      </Item5>
    8686    </RequiredPackages>
    87     <Units Count="11">
     87    <Units Count="12">
    8888      <Unit0>
    8989        <Filename Value="CoolDisk.lpr"/>
     
    145145        <ResourceBaseClass Value="DataModule"/>
    146146      </Unit10>
     147      <Unit11>
     148        <Filename Value="UFileStreamEx.pas"/>
     149        <IsPartOfProject Value="True"/>
     150      </Unit11>
    147151    </Units>
    148152  </ProjectOptions>
  • trunk/CoolDisk.lpr

    r15 r31  
    1010  Forms, tachartlazaruspkg, UFormBenchmark, UProject,
    1111  UConfig, UBlockMap, UDriveScan, Common, TemplateGenerics, UFormOperation,
    12   UFormProject, UFormMain, UPhysDrive, UCore;
     12  UFormProject, UFormMain, UPhysDrive, UCore, UFileStreamEx;
    1313
    1414{$R *.res}
  • trunk/Form/UFormMain.lfm

    r29 r31  
    6262        Height = 24
    6363        Top = 179
    64         Width = 101
     64        Width = 96
    6565        Caption = 'Sector size:'
    6666        ParentColor = False
     
    8686        Height = 24
    8787        Top = 208
    88         Width = 119
     88        Width = 113
    8989        Caption = 'Sector count:'
    9090        ParentColor = False
     
    102102        Height = 24
    103103        Top = 240
    104         Width = 136
     104        Width = 127
    105105        Caption = 'Current sector:'
    106106        ParentColor = False
     
    110110        Height = 24
    111111        Top = 272
    112         Width = 162
     112        Width = 154
    113113        Caption = 'Damaged sectors:'
    114114        ParentColor = False
     
    126126        Height = 24
    127127        Top = 300
    128         Width = 122
     128        Width = 115
    129129        Caption = 'Elapsed time:'
    130130        ParentColor = False
     
    142142        Height = 24
    143143        Top = 328
    144         Width = 142
     144        Width = 135
    145145        Caption = 'Estimated time:'
    146146        ParentColor = False
     
    158158        Height = 24
    159159        Top = 148
    160         Width = 160
     160        Width = 153
    161161        Caption = 'Sectors per Block:'
    162162        ParentColor = False
     
    182182        Height = 24
    183183        Top = 356
    184         Width = 94
     184        Width = 88
    185185        Caption = 'I/O speed:'
    186186        ParentColor = False
     
    190190        Height = 24
    191191        Top = 116
    192         Width = 40
     192        Width = 38
    193193        Caption = 'Size:'
    194194        ParentColor = False
     
    314314        Height = 24
    315315        Top = 16
    316         Width = 107
     316        Width = 100
    317317        Caption = 'Operations:'
    318318        ParentColor = False
  • trunk/Form/UFormMain.pas

    r29 r31  
    520520      BasePrefixMultipliers, SBytes);
    521521    LabelSectorCount.Caption := IntToStr(Project.DriveInfo.SectorCount);
    522     LabelSectorSize.Caption := IntToStr(Project.DriveInfo.SectorSize) + ' ' + SBytes;
     522    LabelSectorSize.Caption := PrefixMultiplier.Add(Project.DriveInfo.SectorSize, BasePrefixMultipliers, SBytes);
    523523  end else begin
    524524    LabelSize.Caption := '';
  • trunk/Form/UFormProject.lfm

    r13 r31  
    99  LCLVersion = '1.7'
    1010  object SpinEditSectorSize: TSpinEdit
    11     Left = 192
     11    Left = 224
    1212    Height = 34
    1313    Top = 152
    1414    Width = 101
    15     MaxValue = 100000
    16     MinValue = 1
     15    MaxValue = 63
     16    OnChange = SpinEditSectorSizeChange
    1717    TabOrder = 0
    1818    Value = 1
     
    9292    ParentColor = False
    9393  end
     94  object Label5: TLabel
     95    Left = 192
     96    Height = 24
     97    Top = 160
     98    Width = 22
     99    Caption = '2^'
     100    ParentColor = False
     101  end
     102  object Label6: TLabel
     103    Left = 341
     104    Height = 24
     105    Top = 160
     106    Width = 11
     107    Caption = '='
     108    ParentColor = False
     109  end
    94110end
  • trunk/Form/UFormProject.pas

    r15 r31  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Spin,
    9   StdCtrls, UProject;
     9  StdCtrls, UProject, Math;
    1010
    1111type
     
    2222    Label3: TLabel;
    2323    Label4: TLabel;
     24    Label5: TLabel;
     25    Label6: TLabel;
    2426    LabelSectorCount: TLabel;
    2527    SpinEditSectorSize: TSpinEdit;
     28    procedure SpinEditSectorSizeChange(Sender: TObject);
    2629  private
     30    procedure UpdateSectorSize;
    2731  public
    2832    procedure Load(Project: TProject);
     
    4246{ TFormProject }
    4347
     48procedure TFormProject.SpinEditSectorSizeChange(Sender: TObject);
     49begin
     50  UpdateSectorSize;
     51end;
     52
     53procedure TFormProject.UpdateSectorSize;
     54begin
     55  Label6.Caption := '= ' + IntToStr(Trunc(IntPower(2, SpinEditSectorSize.Value))) + ' bytes';
     56end;
     57
    4458procedure TFormProject.Load(Project: TProject);
    4559begin
    4660  Core.DriveList.LoadToStrings(ComboBoxDrive.Items);
    4761  EditName.Text := Project.Name;
    48   SpinEditSectorSize.Value := Project.DriveInfo.SectorSize;
     62  SpinEditSectorSize.Value := Trunc(Log2(Project.DriveInfo.SectorSize));
    4963  ComboBoxDrive.ItemIndex := Core.DriveList.IndexOf(Core.DriveList.FindByModel(Project.DriveInfo.Model));
     64  UpdateSectorSize;
    5065end;
    5166
     
    5368begin
    5469  Project.Name := EditName.Text;
    55   Project.DriveInfo.SectorSize := SpinEditSectorSize.Value;
     70  Project.DriveInfo.SectorSize := Trunc(IntPower(2, SpinEditSectorSize.Value));
    5671end;
    5772
  • trunk/Packages/Common/UPrefixMultiplier.pas

    r4 r31  
    3939    (ShortText: 'n'; FullText: 'nano'; Value: 1e-9),
    4040    (ShortText: 'u'; FullText: 'mikro'; Value: 1e-6),
    41     (ShortText: 'm'; FullText: 'mili'; Value: 1e-3),
     41    (ShortText: 'm'; FullText: 'mili'; Value: 1-3),
    4242    (ShortText: ''; FullText: ''; Value: 1e0),
    4343    (ShortText: 'k'; FullText: 'kilo'; Value: 1e3),
  • trunk/UCore.lfm

    r16 r31  
    1818  end
    1919  object XMLConfig1: TXMLConfig
    20     Filename = 'config.xml'
    2120    StartEmpty = False
    2221    RootName = 'CONFIG'
  • trunk/UCore.pas

    r16 r31  
    4040  Project := nil;
    4141  XMLConfig1.Filename := 'config.xml';
     42  Randomize;
    4243end;
    4344
  • trunk/UDriveScan.pas

    r29 r31  
    125125implementation
    126126
     127uses
     128  UFileStreamEx;
     129
    127130resourcestring
    128131  SUnknownRunMode = 'Unknown run mode';
     
    177180function TTestStream.Write(const Buffer; Count: Longint): Longint;
    178181begin
     182  Result := 0;
    179183end;
    180184
    181185function TTestStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64;
    182186begin
     187  Result := 0;
    183188end;
    184189
     
    293298  F: TStream;
    294299  RealSize: Integer;
    295   Buffer: array of Byte;
     300  Buffer: Pointer;
     301  BufferAligned: Pointer;
    296302  I: Integer;
     303  Alignment: Integer;
    297304begin
    298305  try
     
    301308    if ConfigTest then F := TTestStream.Create
    302309    else begin
     310      //if Mode = rmRead then F := TFileStreamEx.Create(DriveName, fmOpenRead, [ffDirect])
     311      //  else if Mode = rmWrite then F := TFileStreamEx.Create(DriveName, fmOpenReadWrite, [ffDirect]);
    303312      if Mode = rmRead then F := TFileStream.Create(DriveName, fmOpenRead)
    304313        else if Mode = rmWrite then F := TFileStream.Create(DriveName, fmOpenReadWrite);
    305314    end;
    306315    try
    307       SetLength(Buffer, SectorSize);
     316      Alignment := SectorSize;
     317      Buffer := GetMem(SectorSize + Alignment);
     318      BufferAligned := Pointer(Int64(Buffer) - (Int64(Buffer) and (Alignment - 1)) + Alignment);
    308319      if Mode = rmWrite then begin
    309320        if not WritePatternRandom then
    310           FillChar(Buffer[0], Length(Buffer), WritePattern)
    311           else for I := 0 to Length(Buffer) - 1 do
    312             Buffer[I] := Random(256);
     321          FillChar(BufferAligned^, SectorSize, WritePattern)
     322          else for I := 0 to SectorSize - 1 do
     323            PByte(Int64(BufferAligned) + I)^ := Random(256);
    313324      end;
    314325      while FSectorCurrent < SectorEnd do begin
     
    317328          DoChange;
    318329          F.Position := FSectorCurrent * SectorSize;
    319           if Mode = rmRead then RealSize := F.Read(Buffer[0], SectorSize)
    320             else if Mode = rmWrite then RealSize := F.Write(Buffer[0], SectorSize)
     330          if Mode = rmRead then RealSize := F.Read(BufferAligned^, SectorSize)
     331            else if Mode = rmWrite then RealSize := F.Write(BufferAligned^, SectorSize)
    321332            else raise Exception.Create(SUnknownRunMode);
    322333        finally
     
    333344        if Terminated then Break;
    334345      end;
     346      FreeMem(Buffer);
    335347    finally
    336348      F.Free;
Note: See TracChangeset for help on using the changeset viewer.