Skip to content

Commit fe60463

Browse files
committed
feat: Automation scripts now have a param
This allows for a single entry to be ran on each automation script
1 parent 44dc9a0 commit fe60463

File tree

5 files changed

+95
-40
lines changed

5 files changed

+95
-40
lines changed

entries/entries.json.example

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"entries-folder": "{...}1brc-ObjectPascal/entries",
44
"results-folder": "{...}1brc-ObjectPascal/results",
55
"bin-folder": "{...}1brc-ObjectPascal/bin",
6-
"input-ssd": "/tmp/measurements-1_000_000_000.txt",
7-
"input-hdd": "{...}1brc-ObjectPascal/data/measurements-1_000_000_000.txt",
6+
"input": "/tmp/measurements-1_000_000_000.txt",
87
"hyperfine": "hyperfine -w 1 -r 10 -N -n '[[name]]' --export-json '[[results-json]]' '[[entry]]'",
98
"lazbuild": "{...}FreePascal_3.0/lazarus/lazbuild",
109
"output-hash": "0000000000000000000000000000000000000000000000000000000000000000",
@@ -17,6 +16,7 @@
1716
"entry-folder": "../baseline/Lazarus/src",
1817
"entry-binary": "baseline",
1918
"lpi": "baseline.lpi",
19+
"dproj": "",
2020
"has-release": true,
2121
"threads": 1,
2222
"run-params": "-i [[input]]"
@@ -29,6 +29,7 @@
2929
"entry-folder": "gcarreno/src",
3030
"entry-binary": "gcarreno",
3131
"lpi": "gcarreno.lpi",
32+
"dproj": "",
3233
"has-release": true,
3334
"threads": 30,
3435
"run-params": "-i [[input]] -t [[threads]]"

utilities/common/utilities.data.config.pas

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ TConfig = class(TObject)
3535
FEntriesFolder: String;
3636
FResultsFolder: String;
3737
FBinFolder: String;
38-
FInputSSD: String;
39-
FInputHDD: String;
38+
FInput: String;
4039
FHyperfine: String;
4140
FLazbuild: String;
4241
FOutputHash: String;
@@ -65,12 +64,9 @@ TConfig = class(TObject)
6564
property BinFolder: String
6665
read FBinFolder
6766
write FBinFolder;
68-
property InputSSD: String
69-
read FInputSSD
70-
write FInputSSD;
71-
property InputHDD: String
72-
read FInputHDD
73-
write FInputHDD;
67+
property Input: String
68+
read FInput
69+
write FInput;
7470
property Hyperfine: String
7571
read FHyperfine
7672
write FHyperfine;
@@ -92,8 +88,7 @@ implementation
9288
cJSONEntriesFolder = 'entries-folder';
9389
cJSONResultsFolder = 'results-folder';
9490
cJSONBinFolder = 'bin-folder';
95-
cJSONInputSSD = 'input-ssd';
96-
cJSONInputHDD = 'input-hdd';
91+
cJSONInput = 'input';
9792
cJSONHyperfine = 'hyperfine';
9893
cJSONLazbuild = 'lazbuild';
9994
cJSONOutpuHash = 'output-hash';
@@ -113,8 +108,7 @@ constructor TConfig.Create;
113108
FEntriesFolder:= '';
114109
FResultsFolder:= '';
115110
FBinFolder:= '';
116-
FInputSSD:= '';
117-
FInputHDD:= '';
111+
FInput:= '';
118112
FHyperfine:= '';
119113
FLazbuild:= '';
120114
FOutputHash:= '';
@@ -177,8 +171,7 @@ procedure TConfig.setFromJSONObject(const AJSONObject: TJSONObject);
177171
FEntriesFolder:= AJSONObject.Get(cJSONEntriesFolder, FEntriesFolder);
178172
FResultsFolder:= AJSONObject.Get(cJSONResultsFolder, FResultsFolder);
179173
FBinFolder:= AJSONObject.Get(cJSONBinFolder, FBinFolder);
180-
FInputSSD:= AJSONObject.Get(cJSONInputSSD, FInputSSD);
181-
FInputHDD:= AJSONObject.Get(cJSONInputHDD, FInputHDD);
174+
FInput:= AJSONObject.Get(cJSONInput, FInput);
182175
FHyperfine:= AJSONObject.Get(cJSONHyperfine, FHyperfine);
183176
FLazbuild:= AJSONObject.Get(cJSONLazbuild, FLazbuild);
184177
FOutputHash:= AJSONObject.Get(cJSONOutpuHash, FOutputHash);

utilities/common/utilities.data.entries.pas

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ TEntry = class(TObject)
4040
FEntryFolder: TJSONStringType;
4141
FEntryBinary: TJSONStringType;
4242
FLPI: TJSONStringType;
43+
FDPROJ: TJSONStringType;
4344
FHasRelease: Boolean;
4445
FThreads: Integer;
4546
FRunParams: TJSONStringType;
@@ -76,6 +77,9 @@ TEntry = class(TObject)
7677
property LPI: TJSONStringType
7778
read FLPI
7879
write FLPI;
80+
property DPROJ: TJSONStringType
81+
read FDPROJ
82+
write FDPROJ;
7983
property HasRelease: Boolean
8084
read FHasRelease
8185
write FHasRelease;
@@ -145,6 +149,7 @@ implementation
145149
cJSONEntryFolder = 'entry-folder';
146150
cJSONEntryBinary = 'entry-binary';
147151
cJSONLPI = 'lpi';
152+
cJSONDPROJ = 'dproj';
148153
cJSONHasRelease = 'has-release';
149154
cJSONThreads = 'threads';
150155
cJSONRunParams = 'run-params';
@@ -167,6 +172,7 @@ constructor TEntry.Create;
167172
FEntryFolder:= '';
168173
FEntryBinary:= '';
169174
FLPI:= '';
175+
FDPROJ:= '';
170176
FHasRelease:= True;
171177
FThreads:= 1;
172178
FRunParams:= '';
@@ -201,6 +207,7 @@ procedure TEntry.setFromJSONObject(const AJSONObject: TJSONObject);
201207
FEntryFolder:= AJSONObject.Get(cJSONEntryFolder, FEntryFolder);
202208
FEntryBinary:= AJSONObject.Get(cJSONEntryBinary, FEntryBinary);
203209
FLPI:= AJSONObject.Get(cJSONLPI, FLPI);
210+
FDPROJ:= AJSONObject.Get(cJSONDPROJ, FDPROJ);
204211
FHasRelease:= AJSONObject.Get(cJSONHasRelease, FHasRelease);
205212
FThreads:= AJSONObject.Get(cJSONThreads, FThreads);
206213
FRunParams:= AJSONObject.Get(cJSONRunParams, FRunParams);

utilities/script_builder/Common/scriptbuilder.common.pas

Lines changed: 76 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ procedure TBuilder.BuildCompileScriptBash;
147147
FScriptStream:= TFileStream.Create(FScriptFile, fmCreate);
148148
try
149149
line:= '#!/bin/bash' + LineEnding + LineEnding;
150-
line:= line + 'echo "******** Compile All ********"' + LineEnding;
150+
line:= line + 'echo "******** Compile ********"' + LineEnding;
151151
line:= line + 'echo' + LineEnding + LineEnding;
152152
for index:= 0 to Pred(FConfig.Entries.Count) do
153153
//for entry in FConfig.Entries do
@@ -156,6 +156,7 @@ procedure TBuilder.BuildCompileScriptBash;
156156
if not FConfig.Entries[index].Active then continue;
157157
if FConfig.Entries[index].Compiler <> cCompilerFPC then continue;
158158
//if FConfig.Entries[index].EntryBinary = cBaselineBinary then continue;
159+
line:= line + 'function ' + FConfig.Entries[index].EntryBinary + '() {' + LineEnding + LineEnding;
159160
line:= line + 'echo "===== '+ FConfig.Entries[index].Name +' ======"' + LineEnding;
160161
if FConfig.Entries[index].HasRelease then
161162
begin
@@ -188,8 +189,30 @@ procedure TBuilder.BuildCompileScriptBash;
188189
LineEnding;
189190
end;
190191
line:= line + 'echo "==========="' + LineEnding;
191-
line:= line + 'echo' + LineEnding + LineEnding;
192+
line:= line + 'echo' + LineEnding + LineEnding + '}' + LineEnding + LineEnding;
192193
end;
194+
line:= line + 'if [ $1 == "" ];then' + LineEnding;
195+
for index:= 0 to Pred(FConfig.Entries.Count) do
196+
begin
197+
if not FConfig.Entries[index].Active then continue;
198+
if FConfig.Entries[index].Compiler <> cCompilerFPC then continue;
199+
line:= line + ' ' + FConfig.Entries[index].EntryBinary + LineEnding;
200+
end;
201+
line:= line + 'else' + LineEnding;
202+
line:= line + ' case $1 in' + LineEnding;
203+
for index:= 0 to Pred(FConfig.Entries.Count) do
204+
begin
205+
if not FConfig.Entries[index].Active then continue;
206+
if FConfig.Entries[index].Compiler <> cCompilerFPC then continue;
207+
line:= line + ' ' + FConfig.Entries[index].EntryBinary + ')' + LineEnding;
208+
line:= line + ' ' + FConfig.Entries[index].EntryBinary + LineEnding;
209+
line:= line + ' ;;' + LineEnding;
210+
end;
211+
line:= line + ' *)' + LineEnding;
212+
line:= line + ' echo "Do not recognise $1"' + LineEnding;
213+
line:= line + ' ;;' + LineEnding;
214+
line:= line + ' esac' + LineEnding;
215+
line:= line + 'fi' + LineEnding;
193216
FScriptStream.WriteBuffer(line[1], Length(line));
194217
finally
195218
FScriptStream.Free;
@@ -214,13 +237,14 @@ procedure TBuilder.BuildTestScriptBash;
214237
FScriptStream:= TFileStream.Create(FScriptFile, fmCreate);
215238
try
216239
line:= '#!/bin/bash' + LineEnding + LineEnding;
217-
line:= line + 'echo "******** Test All ********"' + LineEnding;
240+
line:= line + 'echo "******** Test ********"' + LineEnding;
218241
line:= line + 'echo' + LineEnding + LineEnding;
219242
for index:= 0 to Pred(FConfig.Entries.Count) do
220243
begin
221244
Write(GenerateProgressBar(index+1, FConfig.Entries.Count, 50), lineBreak);
222245
if not FConfig.Entries[index].Active then continue;
223246
//if FConfig.Entries[index].EntryBinary = cBaselineBinary then continue;
247+
line:= line + 'function ' + FConfig.Entries[index].EntryBinary + '() {' + LineEnding + LineEnding;
224248
line:= line + 'echo "===== '+ FConfig.Entries[index].Name +' ======"' + LineEnding;
225249
tmpStr:= Format('%s%s %s', [
226250
IncludeTrailingPathDelimiter(FConfig.BinFolder),
@@ -234,7 +258,7 @@ procedure TBuilder.BuildTestScriptBash;
234258
cReplaceEntryThreads
235259
],
236260
[
237-
FConfig.InputSSD,
261+
FConfig.Input,
238262
IntToStr(FConfig.Entries[index].Threads)
239263
],
240264
[rfReplaceAll]
@@ -254,8 +278,29 @@ procedure TBuilder.BuildTestScriptBash;
254278
FConfig.OutputHash
255279
]) + LineEnding;
256280
line:= line + 'echo "==========="' + LineEnding;
257-
line:= line + 'echo' + LineEnding + LineEnding;
281+
line:= line + 'echo' + LineEnding + LineEnding + '}' + LineEnding + LineEnding;
282+
end;
283+
line:= line + 'if [ $1 == "" ];then' + LineEnding;
284+
for index:= 0 to Pred(FConfig.Entries.Count) do
285+
begin
286+
if not FConfig.Entries[index].Active then continue;
287+
line:= line + ' ' + FConfig.Entries[index].EntryBinary + LineEnding;
288+
end;
289+
line:= line + 'else' + LineEnding;
290+
line:= line + ' case $1 in' + LineEnding;
291+
for index:= 0 to Pred(FConfig.Entries.Count) do
292+
begin
293+
if not FConfig.Entries[index].Active then continue;
294+
if FConfig.Entries[index].Compiler <> cCompilerFPC then continue;
295+
line:= line + ' ' + FConfig.Entries[index].EntryBinary + ')' + LineEnding;
296+
line:= line + ' ' + FConfig.Entries[index].EntryBinary + LineEnding;
297+
line:= line + ' ;;' + LineEnding;
258298
end;
299+
line:= line + ' *)' + LineEnding;
300+
line:= line + ' echo "Do not recognise $1"' + LineEnding;
301+
line:= line + ' ;;' + LineEnding;
302+
line:= line + ' esac' + LineEnding;
303+
line:= line + 'fi' + LineEnding;
259304
FScriptStream.WriteBuffer(line[1], Length(line));
260305
finally
261306
FScriptStream.Free;
@@ -272,13 +317,14 @@ procedure TBuilder.BuildRunScriptBash;
272317
FScriptStream:= TFileStream.Create(FScriptFile, fmCreate);
273318
try
274319
line:= '#!/bin/bash' + LineEnding + LineEnding;
275-
line:= line + 'echo "******** Run All ********"' + LineEnding;
320+
line:= line + 'echo "******** Run ********"' + LineEnding;
276321
line:= line + 'echo' + LineEnding + LineEnding;
277322
for index:= 0 to Pred(FConfig.Entries.Count) do
278323
begin
279324
Write(GenerateProgressBar(index+1, FConfig.Entries.Count, 50), lineBreak);
280325
if not FConfig.Entries[index].Active then continue;
281326
if FConfig.Entries[index].EntryBinary = cBaselineBinary then continue;
327+
line:= line + 'function ' + FConfig.Entries[index].EntryBinary + '() {' + LineEnding + LineEnding;
282328
line:= line + 'echo "===== '+ FConfig.Entries[index].Name +' ======"' + LineEnding;
283329
// Run for SSD
284330
tmpStr:= StringsReplace(
@@ -309,31 +355,37 @@ procedure TBuilder.BuildRunScriptBash;
309355
cReplaceEntryThreads
310356
],
311357
[
312-
FConfig.InputSSD,
358+
FConfig.Input,
313359
IntToStr(FConfig.Entries[index].Threads)
314360
],
315361
[rfReplaceAll]
316362
);
317363
line:= line + 'echo "-- SSD --"' + LineEnding + tmpStr + LineEnding;
318-
319-
// Run for HDD
320-
{tmpStr:= StringsReplace(
321-
tmpStr,
322-
[
323-
FConfig.InputSSD,
324-
cSSD
325-
],
326-
[
327-
FConfig.InputHDD,
328-
cHDD
329-
],
330-
[rfReplaceAll]
331-
);
332-
line:= line + 'echo "-- HDD --"' + LineEnding + tmpStr + LineEnding;}
333-
334364
line:= line + 'echo "==========="' + LineEnding;
335-
line:= line + 'echo' + LineEnding + LineEnding;
365+
line:= line + 'echo' + LineEnding + LineEnding + '}' + LineEnding + LineEnding;
366+
end;
367+
line:= line + 'if [ $1 == "" ];then' + LineEnding;
368+
for index:= 0 to Pred(FConfig.Entries.Count) do
369+
begin
370+
if not FConfig.Entries[index].Active then continue;
371+
if FConfig.Entries[index].EntryBinary = cBaselineBinary then continue;
372+
line:= line + ' ' + FConfig.Entries[index].EntryBinary + LineEnding;
373+
end;
374+
line:= line + 'else' + LineEnding;
375+
line:= line + ' case $1 in' + LineEnding;
376+
for index:= 0 to Pred(FConfig.Entries.Count) do
377+
begin
378+
if not FConfig.Entries[index].Active then continue;
379+
if FConfig.Entries[index].Compiler <> cCompilerFPC then continue;
380+
line:= line + ' ' + FConfig.Entries[index].EntryBinary + ')' + LineEnding;
381+
line:= line + ' ' + FConfig.Entries[index].EntryBinary + LineEnding;
382+
line:= line + ' ;;' + LineEnding;
336383
end;
384+
line:= line + ' *)' + LineEnding;
385+
line:= line + ' echo "Do not recognise $1"' + LineEnding;
386+
line:= line + ' ;;' + LineEnding;
387+
line:= line + ' esac' + LineEnding;
388+
line:= line + 'fi' + LineEnding;
337389
FScriptStream.WriteBuffer(line[1], Length(line));
338390
finally
339391
FScriptStream.Free;

utilities/script_builder/Lazarus/src/scriptbuilder.lpi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,12 @@
104104
<Unit3>
105105
<Filename Value="../../../common/utilities.data.config.pas"/>
106106
<IsPartOfProject Value="True"/>
107+
<UnitName Value="Utilities.Data.Config"/>
107108
</Unit3>
108109
<Unit4>
109110
<Filename Value="../../../common/utilities.data.entries.pas"/>
110111
<IsPartOfProject Value="True"/>
112+
<UnitName Value="Utilities.Data.Entries"/>
111113
</Unit4>
112114
</Units>
113115
</ProjectOptions>

0 commit comments

Comments
 (0)