procedure EncodeStats;
var
FHandle: THandle;
SBInfo: TConsoleScreenBufferInfo;
CLine: Integer;
SL: TStringList;
Coords: TCoord;
ulLength: Cardinal;
procedure Update;
var
I: Integer;
TS: TTimeSpan;
CreationTime, ExitTime, KernelTime, UserTime: TFileTime;
TT: TSystemTime;
I64: Int64;
begin
GetProcessTimes(GetCurrentProcess, CreationTime, ExitTime, KernelTime,
UserTime);
FileTimeToSystemTime(TFileTime(Int64(UserTime) + Int64(KernelTime)), TT);
SL[0] := 'Streams: ' + EncInfo.Processed.ToString + ' / ' +
EncInfo.Count.ToString;
TS := Stopwatch.Elapsed;
SL[1] := 'Time: ' + Format('%0:.2d:%1:.2d:%2:.2d',
[TS.Hours + TS.Days * 24, TS.Minutes, TS.Seconds]) + ' (CPU ' +
Format('%0:.2d:%1:.2d:%2:.2d', [TT.wHour + Pred(TT.wDay) * 24, TT.wMinute,
TT.wSecond]) + ')';
I64 := EncInfo.DecMem0 + EncInfo.DecMem1;
I64 := I64 div 1024;
if StoreDD > -2 then
begin
I := 4;
SL[2] := 'Duplicates: ' + EncInfo.DupCount.ToString + ' (' +
ConvertKB2TB(EncInfo.DecMem2 div 1024) + ') [' +
ConvertKB2TB(EncInfo.DupSize1 div 1024) + ' >> ' +
ConvertKB2TB(EncInfo.DupSize2 div 1024) + '] ';
if StoreDD > 0 then
begin
I := 5;
SL[3] := 'Srep decompression memory: ' +
ConvertKB2TB(EncInfo.SrepMem * 1024) + ' [' +
ConvertKB2TB((EncInfo.SrepMem * 1024) + (EncInfo.DecMem3 div 1024)) +
IfThen(EncInfo.DecMem3 > 0, '*', '') + '] ';
end;
end
else
I := 3;
SL[I] := 'Size: ' + ConvertKB2TB(EncInfo.InSize div 1024) +
IfThen(StoreDD > -2,
' >> ' + ConvertKB2TB((EncInfo.InflSize + EncInfo.DupSize2) div 1024), '')
+ ' >> ' + ConvertKB2TB(EncInfo.InflSize div 1024) +
IfThen(StoreDD > 0, ' >> ' + ConvertKB2TB((EncInfo.SrepSize) div 1024),
'') + IfThen(COMPRESS, ' >> ' + ConvertKB2TB((EncInfo.CompSize) div 1024),
'') + ' ';
SetConsoleCursorPosition(FHandle, Coords);
WriteConsole(FHandle, PChar(SL.Text), Length(SL.Text), ulLength, nil);
end;
begin
FHandle := GetStdHandle(STD_ERROR_HANDLE);
GetConsoleScreenBufferInfo(FHandle, SBInfo);
Coords.X := 0;
Coords.Y := SBInfo.dwCursorPosition.Y;
SL := TStringList.Create;
SL.Add('Streams: 0 / 0');
SL.Add('Time: 00:00:00');
if StoreDD > -2 then
begin
SL.Add('Duplicates: 0 (0.00 MB) [0.00 MB >> 0.00 MB]');
if StoreDD > 0 then
SL.Add('Srep decompression memory: 0.00 MB [0.00MB]');
end;
SL.Add('');
SL.Add('Size: ');
SL.Add('');
while Stopwatch.IsRunning do
begin
Update;
Sleep(500);
end;
Update;
SL.Free;
end;