Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions generator/Common/generate.common.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,7 +37,7 @@ TGenerator = class(TObject)
end;

{$IFNDEF FPC}
TStringArray = array of string;
TStringArray = array of Utf8String;
TWriteBufStream = TFileStream;
{$ENDIF}

Expand All @@ -48,7 +48,8 @@ implementation
{$IFDEF FPC}
, streamex
{$ELSE}
, System.Diagnostics
, System.Diagnostics
{$IF defined(MSWINDOWS)}, Winapi.Windows{$ENDIF}
{$ENDIF}
;

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion generator/Common/generate.console.pas
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface
var
inputFilename: String = '';
outputFilename: String = '';
lineCount: Int64 = 0;
lineCount: Integer = 0;

procedure WriteHelp;

Expand Down
4 changes: 2 additions & 2 deletions generator/Delphi/src/generator.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion generator/Lazarus/src/generator.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down