Skip to content

Commit 82d1f50

Browse files
committed
parameter -s to specify the dictionary size
1 parent acbc30a commit 82d1f50

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

entries/ghatem-fpc/src/OneBRCproj.lpr

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ TOneBRCApp = class(TCustomApplication)
1818
private
1919
FFileName: string;
2020
FThreadCount: Integer;
21+
FDictSize: Integer;
2122
procedure RunOneBRC;
2223
protected
2324
procedure DoRun; override;
@@ -33,7 +34,7 @@ procedure TOneBRCApp.RunOneBRC;
3334
var
3435
vOneBRC: TOneBRC;
3536
begin
36-
vOneBRC := TOneBRC.Create (FThreadCount);
37+
vOneBRC := TOneBRC.Create (FThreadCount, FDictSize);
3738
try
3839
try
3940
vOneBRC.mORMotMMF(FFileName);
@@ -88,15 +89,17 @@ procedure TOneBRCApp.DoRun;
8889
ErrorMsg: String;
8990
begin
9091
// quick check parameters
91-
ErrorMsg:= CheckOptions(Format('%s%s%s%s:',[
92+
ErrorMsg:= CheckOptions(Format('%s%s%s%s%s:',[
9293
cShortOptHelp,
9394
cShortOptThread,
95+
cShortOptDictSize,
9496
cShortOptVersion,
9597
cShortOptInput
9698
]),
9799
[
98100
cLongOptHelp,
99101
cLongOptThread+':',
102+
cLongOptDictSize+':',
100103
cLongOptVersion,
101104
cLongOptInput+':'
102105
]
@@ -126,6 +129,11 @@ procedure TOneBRCApp.DoRun;
126129
FThreadCount := StrToInt (GetOptionValue(cShortOptThread, cLongOptThread));
127130
end;
128131

132+
FDictSize := 45003;
133+
if HasOption(cShortOptDictSize, cLongOptDictSize) then begin
134+
FDictSize := StrToInt (GetOptionValue(cShortOptDictSize, cLongOptDictSize));
135+
end;
136+
129137
if HasOption(cShortOptInput, cLongOptInput) then begin
130138
FFileName := GetOptionValue(
131139
cShortOptInput,

entries/ghatem-fpc/src/baseline.console.pas

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ interface
2121
cLongOptInput = 'input-file';
2222
cShortOptThread: Char = 't';
2323
cLongOptThread = 'threads';
24+
cShortOptDictSize: Char = 's';
25+
cLongOptDictSize = 'size';
2426
{$ELSE}
2527
cOptionHelp: array of string = ['-h', '--help'];
2628
cOptionVersion: array of string = ['-v', '--version'];

entries/ghatem-fpc/src/onebrc.pas

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ interface
1010

1111
function RoundExDouble(const ATemp: Double): Double; inline;
1212

13+
{$WRITEABLECONST ON}
1314
const
1415
cDictSize: Integer = 45003;
16+
{$WRITEABLECONST OFF}
1517

1618
type
1719

@@ -63,7 +65,7 @@ TOneBRC = class
6365
procedure ExtractLineData(const aStart: Int64; const aEnd: Int64; out aLength: ShortInt; out aTemp: SmallInt); inline;
6466

6567
public
66-
constructor Create (const aThreadCount: UInt16);
68+
constructor Create (const aThreadCount: UInt16; const aDictSize: Integer);
6769
destructor Destroy; override;
6870
function mORMotMMF (const afilename: string): Boolean;
6971
procedure DispatchThreads;
@@ -249,9 +251,11 @@ procedure TOneBRC.ExtractLineData(const aStart: Int64; const aEnd: Int64; out aL
249251

250252
//---------------------------------------------------
251253

252-
constructor TOneBRC.Create (const aThreadCount: UInt16);
254+
constructor TOneBRC.Create (const aThreadCount: UInt16; const aDictSize: Integer);
253255
var I: UInt16;
254256
begin
257+
cDictSize := aDictSize;
258+
255259
FThreadCount := aThreadCount;
256260
SetLength (FStationsDicts, aThreadCount);
257261
SetLength (FThreads, aThreadCount);

0 commit comments

Comments
 (0)