Skip to content

Commit 48792c0

Browse files
authored
Merge pull request #74 from ikelaiah/ikelaiah-rev05
Ikelaiah rev05
2 parents e4f066c + ec7dd02 commit 48792c0

File tree

3 files changed

+191
-142
lines changed

3 files changed

+191
-142
lines changed

entries/ikelaiah/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Run `sha256sum` on your output.
5555

5656
```bash
5757
$ sha256sum.exe ikelaiah-output.txt
58-
db3d79d31b50daa8c03a1e4f2025029cb137f9971aa04129d8bca004795ae524 *ikelaiah-output.txt
58+
683bb3d247f53bab96e98983771d66bc9d7dbfb38aa3fecac4c04b8ab29e3032 *ikelaiah-output.txt
5959
```
6060

6161
## Help
@@ -78,7 +78,7 @@ Use `-v` to check version.
7878

7979
```bash
8080
$ ./OneBRC.exe -v
81-
OneBRC version 1.3
81+
OneBRC version 1.5
8282
```
8383

8484
## Authors
@@ -110,7 +110,12 @@ Iwan Kelaiah
110110
* Replaced `TFileStream` with `TBufferedFileStream`. Now, ~1 min faster. Total time for 1BRC (Object Pascal) is now approx. 11 mins on my laptop.
111111
* Replaced `TDictionary` with `TGHashMapQP`. Now ~4 mins faster. Total time for 1BRC (Object Pascal) is now approx. 7 mins on my laptop.
112112
* Replaced `StringReplace` with a simpler function avoiding creating a new string for each replacement. This saves 15-30 seconds on my laptop. The run time now is approx. 6-8 minutes.
113-
* Updated the rounding method as per the latest README.md in the 1BRC GitHub page.
113+
* Updated the rounding method as per the latest `README.md` in the 1BRC GitHub page.
114+
115+
* 1.5
116+
* Revision release - Sequential approach. 6-8 mins on my Inspiron 15 7510 laptop (No improvements on speed).
117+
* Encapsulate process in a class.
118+
* Updated the rounding method as per the latest `README.md` in the 1BRC GitHub page.
114119

115120
## License
116121

entries/ikelaiah/src/OneBRC.lpr

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
WeatherStation;
3737

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

4141
type
4242

@@ -57,6 +57,7 @@ TOneBRC = class(TCustomApplication)
5757
var
5858
ErrorMsg: string;
5959
filename: string = '';
60+
weatherStation: TWeatherStation;
6061
begin
6162
// quick check parameters
6263
ErrorMsg := CheckOptions('hvi:', ['help', 'version', 'input:']);
@@ -92,7 +93,7 @@ TOneBRC = class(TCustomApplication)
9293
filename := GetOptionValue('i', 'input');
9394
end;
9495

95-
if (length(filename) < 4) then
96+
if not FileExists(fileName) then
9697
begin
9798
WriteLn('Input file seems invalid.');
9899
WriteHelp;
@@ -102,13 +103,17 @@ TOneBRC = class(TCustomApplication)
102103

103104
// Start the main algorithm ////////////////////////////////////////////////
104105
try
105-
WeatherStation.ProcessTempMeasurementsV4a(filename);
106+
weatherStation := TWeatherStation.Create(filename);
107+
try
108+
weatherStation.ProcessMeasurements;
109+
finally
110+
weatherStation.Free;
111+
end;
106112
except
107113
on E: Exception do
108114
WriteLn('Error: ' + E.Message);
109115
end;
110116

111-
112117
// Stop program loop ///////////////////////////////////////////////////////
113118
Terminate;
114119
end;

0 commit comments

Comments
 (0)