Skip to content

Commit 98b14b3

Browse files
authored
Merge pull request #152 from ikelaiah/ikelaiah-rev11
Update - revision 11
2 parents 1212c45 + 2527529 commit 98b14b3

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

entries/ikelaiah/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ Iwan Kelaiah
141141
* Reduced buffer for `TStreamReader` to `65536 * 2`. This saves approx 5 seconds.
142142
* Changed hashmap from `TGHashMapLP` (linear probing) to `TGHashMapQP` (quadratic probing). This saves approx 5 seconds.
143143

144+
* 1.11
145+
* Revision release - Sequential approach. 3-5 mins on my Inspiron 15 7510 laptop, around 2m55s (no improvement on speed).
146+
* Replaced `LGenerics` with `Generics.Collections` for the time being.
147+
144148
## License
145149

146150
This project is licensed under the MIT License - see the LICENSE.md file for details
@@ -166,4 +170,4 @@ Inspiration, code snippets, libraries, etc.
166170
5. Shraddha Agrawal - https://www.bytesizego.com/blog/one-billion-row-challenge-go.
167171
- The advice for not storing measurements for each station in a data structure.
168172
6. Arman Hajisafi - https://arman-hs.github.io
169-
- Encouragements and inspirations.
173+
- Encouragements and inspirations.

entries/ikelaiah/src/OneBRC.lpi

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
</Target>
2727
<SearchPaths>
2828
<IncludeFiles Value="$(ProjOutDir)"/>
29-
<OtherUnitFiles Value="..\..\..\baseline\Common"/>
29+
<OtherUnitFiles Value="..\..\..\baseline;lgenerics"/>
3030
<UnitOutputDirectory Value="..\..\..\bin\lib\$(TargetCPU)-$(TargetOS)"/>
3131
</SearchPaths>
3232
<Parsing>
@@ -69,7 +69,7 @@
6969
</Target>
7070
<SearchPaths>
7171
<IncludeFiles Value="$(ProjOutDir)"/>
72-
<OtherUnitFiles Value="..\..\..\baseline\Common"/>
72+
<OtherUnitFiles Value="..\..\..\baseline\Common;lgenerics"/>
7373
<UnitOutputDirectory Value="..\..\..\bin\lib\$(TargetCPU)-$(TargetOS)"/>
7474
</SearchPaths>
7575
<CodeGeneration>
@@ -100,11 +100,6 @@
100100
<RunParams>
101101
<FormatVersion Value="2"/>
102102
</RunParams>
103-
<RequiredPackages Count="1">
104-
<Item1>
105-
<PackageName Value="LGenerics"/>
106-
</Item1>
107-
</RequiredPackages>
108103
<Units Count="3">
109104
<Unit0>
110105
<Filename Value="OneBRC.lpr"/>

entries/ikelaiah/src/OneBRC.lpr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
WeatherStation;
3737

3838
const
39-
version = '1.5';
39+
version = '1.11';
4040

4141
type
4242

entries/ikelaiah/src/weatherstation.pas

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ interface
1010
, Math
1111
, streamex
1212
, bufstream
13-
, lgHashMap
13+
//, lgHashMap
14+
, generics.Collections
1415
{$IFDEF DEBUG}
1516
, Stopwatch
1617
{$ENDIF}
@@ -35,11 +36,11 @@ TStat = record
3536

3637
type
3738
// Using this dictionary, now approx 4 mins faster than Generics.Collections.TDictionary
38-
TWeatherDictionaryLG = specialize TGHashMapQP<ShortString, PStat>;
39+
TWeatherDictionaryLG = specialize TFastHashMap<ShortString, PStat>;
3940

4041
type
4142
// a type for storing valid lookup temperature
42-
TValidTemperatureDictionary = specialize TGHashMapQP<ShortString, int64>;
43+
TValidTemperatureDictionary = specialize TFastHashMap<ShortString, int64>;
4344

4445
type
4546
// Create a class to encapsulate the temperature observations of each weather station.
@@ -121,10 +122,10 @@ constructor TWeatherStation.Create(const filename: string);
121122
// Create a lookup
122123
self.lookupStrFloatToIntList := TValidTemperatureDictionary.Create;
123124
// Set expected capacity - saves 10 seconds.
124-
self.lookupStrFloatToIntList.EnsureCapacity(44691);
125+
self.lookupStrFloatToIntList.Capacity := 44691;
125126
// Create a dictionary
126127
weatherDictionary := TWeatherDictionaryLG.Create;
127-
weatherDictionary.EnsureCapacity(44691);
128+
weatherDictionary.Capacity := 44691;
128129
// Create a TStringList for sorting
129130
weatherStationList := TStringList.Create;
130131
end;

0 commit comments

Comments
 (0)