program AppIniFileStorageTest;

{$APPTYPE CONSOLE}

{$IFOPT O+}{$WEAKLINKRTTI ON}{$ENDIF}
{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}

{$R *.res}

uses
  Winapi.Windows, System.SysUtils, System.Diagnostics,
  JvAppStorage, JvAppIniStorage;

{$SETPEOPTFLAGS $140} // set ASLR and NX/DEP
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
{$SetPEFlags IMAGE_FILE_RELOCS_STRIPPED}

var
  tSettingsIni: TJvAppIniFileStorage;
  tSW: TStopWatch;
  tCnt: Integer;
begin
  try
    tSettingsIni := TJvAppIniFileStorage.Create(nil);
    tSettingsIni.Encoding := TEncoding.UTF8;
    tSettingsIni.AutoFlush := False;
    tSettingsIni.AutoReload := False;
    tSettingsIni.ReadOnly := True;
    tSettingsIni.Location := flCustom;
    tSettingsIni.FileName := 'test.ini';
    tSettingsIni.Reload;

    tSW := TStopWatch.Create;
    tSW.Start;

    for tCnt := 1 to 10000 do
    begin
      tSettingsIni.PathExists('BDE SQL Drivers Command Information');
      tSettingsIni.PathExists('bogus');
      tSettingsIni.PathExists('(BDE) Version Mismatch Category');
    end;

    for tCnt := 1 to 10000 do
    begin
      tSettingsIni.ValueStored('(BDE) Query related\11972');
      tSettingsIni.ValueStored('(BDE) Data Repository related\13578');
      tSettingsIni.ValueStored('BDE SQL Drivers Command Information\4830');
    end;

    Writeln('Elapsed: ' + FloatToStr(tSW.Elapsed.TotalMilliseconds));
    Readln;
    tSettingsIni.Free;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.
