Skip to content

Commit a87cb3c

Browse files
committed
refactor: Using 64K for buffer capacity
1 parent ccfe31c commit a87cb3c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Diff for: generator/Common/generate.common.pas

+10-2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ procedure TGenerator.BuildStationNames;
7777
streamReader: TStreamReader;
7878
entry: String;
7979
count: Int64 = 0;
80+
start, stop: QWord;
8081
begin
8182
WriteLn('Building Weather Stations...');
8283
// Load the Weather Station names
@@ -86,6 +87,7 @@ procedure TGenerator.BuildStationNames;
8687
try
8788
streamReader:= TStreamReader.Create(inputStream);
8889
try
90+
start:= GetTickCount64;
8991
while not streamReader.Eof do
9092
begin
9193
entry:= streamReader.ReadLine;
@@ -97,6 +99,7 @@ procedure TGenerator.BuildStationNames;
9799
Inc(count);
98100
end;
99101
end;
102+
stop:= GetTickCount64;
100103
finally
101104
streamReader.Free;
102105
end;
@@ -108,7 +111,11 @@ procedure TGenerator.BuildStationNames;
108111
begin
109112
raise Exception.Create(Format('File "%s" not found.', [ FInputFile ]));
110113
end;
111-
WriteLn('Done.');
114+
WriteLn(Format('Done: Processed %d entries from a total of %d weather stations in %d ms', [
115+
count,
116+
FStationNames.Count,
117+
stop-start
118+
]));
112119
WriteLn;
113120
end;
114121

@@ -147,7 +154,8 @@ procedure TGenerator.Generate;
147154
progressBatch:= floor(FLineCount * (batchPercent / 100));
148155

149156
try
150-
outputBufWriter:= TWriteBufStream.Create(outputFileStream, 20*1024*1024);
157+
//outputBufWriter:= TWriteBufStream.Create(outputFileStream, 4*1024);
158+
outputBufWriter:= TWriteBufStream.Create(outputFileStream, 64*1024);
151159
try
152160
Write(GenerateProgressBar(1, FLineCount, 50), #13);
153161
// Generate the file

0 commit comments

Comments
 (0)