You are not logged in.
Pages: 1
I'm using TPrecisionTimer to time a long running procedure. Would it be possible to change the Time function to return hours and minutes as well?
Changing MicroSecToString in SynCommons.pas seems to work:
function MicroSecToString(Micro: QWord): RawUTF8;
function TwoDigitToString(value: cardinal): RawUTF8;
var L: integer;
begin
UInt32ToUtf8(value,result);
L := length(result);
if L=1 then
result := '0.0'+result else // '3' -> '0.03'
if L=2 then
result := '0.'+result else // '35' -> '0.35'
insert('.',result,L-1); // '103' -> '1.03'
end;
var seconds: Cardinal;
begin
if Micro<=0 then
result := '0us' else
if Micro<1000 then
result := SmallUInt32UTF8[Micro]+'us' else
if Micro<1000*1000 then
result := TwoDigitToString(Int64Rec(Micro).Lo div 10)+'ms' else
if Micro<1000*1000*60 then
result := TwoDigitToString(Micro div (10*1000))+'s' else
begin
seconds := Micro div (1000*1000);
if seconds < 60*60 then
result := UInt32ToUtf8(seconds div 60)+'m '+UInt32ToUtf8(seconds mod 60)+'s'
else
result := UInt32ToUtf8(seconds div (60*60))+'h '+
UInt32ToUtf8((seconds mod (60*60)) div 60)+'m '+
UInt32ToUtf8(seconds mod 60)+'s'
end;
end;
Offline
Okay, Thanks.
Offline
Pages: 1