From c052a010d68517accd6725f3303f331984bd0fdb Mon Sep 17 00:00:00 2001 From: Iwan Kelaiah Date: Sun, 5 May 2024 09:52:05 +1000 Subject: [PATCH] Update - revision 11. --- entries/ikelaiah/README.md | 11 ++++++++++- entries/ikelaiah/src/OneBRC.lpi | 9 ++------- entries/ikelaiah/src/OneBRC.lpr | 2 +- entries/ikelaiah/src/weatherstation.pas | 11 ++++++----- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/entries/ikelaiah/README.md b/entries/ikelaiah/README.md index db4c9bc..a67fa55 100644 --- a/entries/ikelaiah/README.md +++ b/entries/ikelaiah/README.md @@ -136,6 +136,15 @@ Iwan Kelaiah * Use `ShortString` whenever possible. This saves approx 20 seconds. * Pre-allocate initial size for dictionaries. saves approx 20 seconds. +* 1.10 + * Revision release - Sequential approach. 3-5 mins on my Inspiron 15 7510 laptop, around 2m55s (a little improvement on speed). + * 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 @@ -161,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. \ No newline at end of file diff --git a/entries/ikelaiah/src/OneBRC.lpi b/entries/ikelaiah/src/OneBRC.lpi index 816a8c5..b285ee4 100644 --- a/entries/ikelaiah/src/OneBRC.lpi +++ b/entries/ikelaiah/src/OneBRC.lpi @@ -26,7 +26,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -100,11 +100,6 @@ - - - - - diff --git a/entries/ikelaiah/src/OneBRC.lpr b/entries/ikelaiah/src/OneBRC.lpr index e22369f..d007b17 100644 --- a/entries/ikelaiah/src/OneBRC.lpr +++ b/entries/ikelaiah/src/OneBRC.lpr @@ -36,7 +36,7 @@ WeatherStation; const - version = '1.5'; + version = '1.11'; type diff --git a/entries/ikelaiah/src/weatherstation.pas b/entries/ikelaiah/src/weatherstation.pas index 7873610..7147cde 100644 --- a/entries/ikelaiah/src/weatherstation.pas +++ b/entries/ikelaiah/src/weatherstation.pas @@ -10,7 +10,8 @@ interface , Math , streamex , bufstream - , lgHashMap + //, lgHashMap + , generics.Collections {$IFDEF DEBUG} , Stopwatch {$ENDIF} @@ -35,11 +36,11 @@ TStat = record type // Using this dictionary, now approx 4 mins faster than Generics.Collections.TDictionary - TWeatherDictionaryLG = specialize TGHashMapLP; + TWeatherDictionaryLG = specialize TFastHashMap; type // a type for storing valid lookup temperature - TValidTemperatureDictionary = specialize TGHashMapLP; + TValidTemperatureDictionary = specialize TFastHashMap; type // Create a class to encapsulate the temperature observations of each weather station. @@ -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;