diff --git a/generator/Common/generate.common.pas b/generator/Common/generate.common.pas index 18c902e..b93b32a 100644 --- a/generator/Common/generate.common.pas +++ b/generator/Common/generate.common.pas @@ -24,8 +24,8 @@ TGenerator = class(TObject) FStationNames: TStringList; procedure BuildStationNames; - function GenerateProgressBar(APBPosition, APBMax, APBWIdth, AFileSize: Int64; - ATimeElapsed: TDateTime): String; + function GenerateProgressBar(APBPosition, APBMax, APBWIdth: Integer; + AFileSize: Int64; ATimeElapsed: TDateTime): String; function Rng1brc(Range: longint): longint; protected public @@ -37,7 +37,7 @@ TGenerator = class(TObject) end; {$IFNDEF FPC} - TStringArray = array of string; + TStringArray = array of Utf8String; TWriteBufStream = TFileStream; {$ENDIF} @@ -48,7 +48,8 @@ implementation {$IFDEF FPC} , streamex {$ELSE} -, System.Diagnostics +, System.Diagnostics +{$IF defined(MSWINDOWS)}, Winapi.Windows{$ENDIF} {$ENDIF} ; @@ -113,7 +114,7 @@ procedure TGenerator.BuildStationNames; end; stop := GetTickCount64; {$ELSE} - start := TStopwatch.GetTimeStamp; + start := {$IF defined(MSWINDOWS)}GetTickCount64{$ELSE}TStopwatch.GetTimeStamp{$ENDIF}; while not streamReader.EndOfStream do begin entry := streamReader.ReadLine; @@ -124,7 +125,7 @@ procedure TGenerator.BuildStationNames; Inc(count); end; end; - stop := TStopwatch.GetTimeStamp; + stop := {$IF defined(MSWINDOWS)}GetTickCount64{$ELSE}TStopwatch.GetTimeStamp{$ENDIF}; {$ENDIF} finally streamReader.Free; @@ -143,14 +144,13 @@ procedure TGenerator.BuildStationNames; WriteLn; end; -function TGenerator.GenerateProgressBar(APBPosition, APBMax, APBWIdth, AFileSize: Int64; - ATimeElapsed: TDateTime): String; +function TGenerator.GenerateProgressBar(APBPosition, APBMax, APBWIdth: Integer; AFileSize: Int64; ATimeElapsed: TDateTime): String; var percentDone: Double; filled: Integer; begin - percentDone := (100 * APBPosition) / APBMax; - filled := (APBWIdth * APBPosition) div APBMax; + percentDone := 100 * (APBPosition / APBMax); + filled := trunc(APBWIdth * (percentDone / 100)); Result := '['; Result := Result + StringOfChar('#', filled); Result := Result + StringOfChar('-', APBWIdth - filled); @@ -178,12 +178,11 @@ function TGenerator.Rng1brc(Range: Integer): Integer; procedure TGenerator.Generate; var - index, progressCount, progressBatch: Int64; - stationId: Int64; - randomTemp: Integer; + index, progressCount, progressBatch: Integer; + stationId, randomTemp: Integer; randomTempStr: String[4]; outputFileStream: TFileStream; - chunkLine, randomTempFinal: String; + chunkLine, randomTempFinal: Utf8String; stationArray, temperatureArray: TStringArray; LenStationArray, LenTemperatureArray: Array of Integer; chunkCount, chunkLen, stationsCount, temperaturesCount: Integer; diff --git a/generator/Common/generate.console.pas b/generator/Common/generate.console.pas index fe34611..e071cb0 100644 --- a/generator/Common/generate.console.pas +++ b/generator/Common/generate.console.pas @@ -44,7 +44,7 @@ interface var inputFilename: String = ''; outputFilename: String = ''; - lineCount: Int64 = 0; + lineCount: Integer = 0; procedure WriteHelp; diff --git a/generator/Delphi/src/generator.dpr b/generator/Delphi/src/generator.dpr index 49307ed..1643e1e 100644 --- a/generator/Delphi/src/generator.dpr +++ b/generator/Delphi/src/generator.dpr @@ -8,7 +8,7 @@ uses generate.common in '..\..\Common\generate.common.pas', generate.console in '..\..\Common\generate.console.pas'; -{$I version.inc} +{$I '..\..\Common\version.inc'} type @@ -193,7 +193,7 @@ begin begin tmpLineCount := FParams.ValueFromIndex[J].Replace('_', '', [rfReplaceAll]); - if not TryStrToInt64(tmpLineCount, lineCount) then + if not TryStrToInt(tmpLineCount, lineCount) then begin WriteLn(Format(rsInvalidInteger, [tmpLineCount])); inc(invalid); diff --git a/generator/Lazarus/src/generator.lpr b/generator/Lazarus/src/generator.lpr index 4fd185b..d54327e 100644 --- a/generator/Lazarus/src/generator.lpr +++ b/generator/Lazarus/src/generator.lpr @@ -111,7 +111,7 @@ procedure TOneBRCGenerator.DoRun; cLongOptNumber ); tmpLineCount:= StringReplace(tmpLineCount, '_', '', [rfReplaceAll]); - if not TryStrToInt64(tmpLineCount, lineCount) then + if not TryStrToInt(tmpLineCount, lineCount) then begin WriteLn(Format(rsInvalidInteger, [ tmpLineCount ])); Terminate;