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
6 changes: 5 additions & 1 deletion entries/ikelaiah/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ Iwan Kelaiah
* Reduced buffer for `TStreamReader` to `65536 * 2`. This saves approx 5 seconds.
* Changed hashmap from `TGHashMapLP` (linear probing) to `TGHashMapQP` (quadratic probing). This saves approx 5 seconds.

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

## License

This project is licensed under the MIT License - see the LICENSE.md file for details
Expand All @@ -166,4 +170,4 @@ Inspiration, code snippets, libraries, etc.
5. Shraddha Agrawal - https://www.bytesizego.com/blog/one-billion-row-challenge-go.
- The advice for not storing measurements for each station in a data structure.
6. Arman Hajisafi - https://arman-hs.github.io
- Encouragements and inspirations.
- Encouragements and inspirations.
9 changes: 2 additions & 7 deletions entries/ikelaiah/src/OneBRC.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="..\..\..\baseline\Common"/>
<OtherUnitFiles Value="..\..\..\baseline;lgenerics"/>
<UnitOutputDirectory Value="..\..\..\bin\lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
Expand Down Expand Up @@ -69,7 +69,7 @@
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="..\..\..\baseline\Common"/>
<OtherUnitFiles Value="..\..\..\baseline\Common;lgenerics"/>
<UnitOutputDirectory Value="..\..\..\bin\lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<CodeGeneration>
Expand Down Expand Up @@ -100,11 +100,6 @@
<RunParams>
<FormatVersion Value="2"/>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LGenerics"/>
</Item1>
</RequiredPackages>
<Units Count="3">
<Unit0>
<Filename Value="OneBRC.lpr"/>
Expand Down
2 changes: 1 addition & 1 deletion entries/ikelaiah/src/OneBRC.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
WeatherStation;

const
version = '1.5';
version = '1.11';

type

Expand Down
11 changes: 6 additions & 5 deletions entries/ikelaiah/src/weatherstation.pas
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ interface
, Math
, streamex
, bufstream
, lgHashMap
//, lgHashMap
, generics.Collections
{$IFDEF DEBUG}
, Stopwatch
{$ENDIF}
Expand All @@ -35,11 +36,11 @@ TStat = record

type
// Using this dictionary, now approx 4 mins faster than Generics.Collections.TDictionary
TWeatherDictionaryLG = specialize TGHashMapQP<ShortString, PStat>;
TWeatherDictionaryLG = specialize TFastHashMap<ShortString, PStat>;

type
// a type for storing valid lookup temperature
TValidTemperatureDictionary = specialize TGHashMapQP<ShortString, int64>;
TValidTemperatureDictionary = specialize TFastHashMap<ShortString, int64>;

type
// Create a class to encapsulate the temperature observations of each weather station.
Expand Down Expand Up @@ -121,10 +122,10 @@ constructor TWeatherStation.Create(const filename: string);
// Create a lookup
self.lookupStrFloatToIntList := TValidTemperatureDictionary.Create;
// Set expected capacity - saves 10 seconds.
self.lookupStrFloatToIntList.EnsureCapacity(44691);
self.lookupStrFloatToIntList.Capacity := 44691;
// Create a dictionary
weatherDictionary := TWeatherDictionaryLG.Create;
weatherDictionary.EnsureCapacity(44691);
weatherDictionary.Capacity := 44691;
// Create a TStringList for sorting
weatherStationList := TStringList.Create;
end;
Expand Down