Skip to content

Commit 747e9b1

Browse files
authored
Merge pull request #53 from paweld/gus
fix to "changes in results analysis"
2 parents 7aab38c + 8e95406 commit 747e9b1

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

utilities/common/utilities.data.hyperfine.pas

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface
1010
, fpjson
1111
, fpjsonrtti
1212
, fgl
13+
, typinfo
1314
;
1415

1516
const
@@ -46,6 +47,7 @@ THyperfineResult = class(TObject)
4647

4748
procedure setFromJSONData(const AJSONData: TJSONData);
4849
procedure setFromJSONObject(const AJSONObject: TJSONObject);
50+
procedure OnRestoreProperty(Sender: TObject; AObject: TObject; Info: PPropInfo; AValue: TJSONData; var Handled: Boolean);
4951
protected
5052
public
5153
constructor Create;
@@ -176,12 +178,32 @@ procedure THyperfineResult.setFromJSONObject(const AJSONObject: TJSONObject);
176178
jds: TJSONDestreamer;
177179
begin
178180
jds := TJSONDestreamer.Create(nil);
181+
jds.OnRestoreProperty := @OnRestoreProperty;
179182
try
180183
jds.JSONToObject(AJSONObject.AsJSON, Self);
181184
finally
182185
jds.Free;
183186
end;
184187
end;
185188

189+
procedure THyperfineResult.OnRestoreProperty(Sender: TObject; AObject: TObject; Info: PPropInfo; AValue: TJSONData; var Handled: Boolean);
190+
var
191+
i: Integer;
192+
begin
193+
Handled := False;
194+
if (Info^.Name = 'times') then
195+
begin
196+
Handled := True;
197+
for i := 0 to AValue.Count - 1 do
198+
THyperfineResult(AObject).times.Add(Avalue.Items[i].AsFloat);
199+
end
200+
else if (Info^.Name = 'exit_codes') then
201+
begin
202+
Handled := True;
203+
for i := 0 to AValue.Count - 1 do
204+
THyperfineResult(AObject).exit_codes.Add(Avalue.Items[i].AsInteger);
205+
end;
206+
end;
207+
186208
end.
187209

utilities/results_generator/Common/resultsgenerator.common.pas

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,9 @@ function TResults.FormatTime(ATime: Double): String;
116116
begin
117117
Result:= '';
118118
intPart:= Trunc(ATime);
119-
minutes:= 0;
120-
if intPart >= 60 then
121-
begin
122-
repeat
123-
Inc(minutes);
124-
Dec(intPart, 60);
125-
until intPart < 60;
126-
end;
127-
millis:= Copy(
128-
FloatToStr(ATime),
129-
Pos('.', FloatToStr(ATime)) + 1,
130-
4
131-
);
119+
millis := FormatFloat('000', Trunc((ATime - intPart) * 1000));
120+
minutes := intPart div 60;
121+
intPart := intPart mod 60;
132122
Result:= Format('%d:%d.%s',[
133123
minutes,
134124
intPart,

0 commit comments

Comments
 (0)