show runnable module compilation duration and imrpove duration accuracy

close #377
This commit is contained in:
Basile Burg 2019-01-16 12:51:10 +01:00
parent 4a65a77468
commit cafd08ca05
2 changed files with 32 additions and 5 deletions

View File

@ -325,6 +325,9 @@ type
// Converts all leading whites to tabs. Fails if width doesn't fivide number of spaces.
function leadingSpacesToTabs(const value: string; width: integer): string;
// Converts the delta between two calls to GetTickCount64 to a string indicating a duration.
function formatTicksAsDuration(ticks: UInt64): string;
var
// additional directories to find background tools
additionalPath: string;
@ -1106,6 +1109,20 @@ begin
end;
end;
function formatTicksAsDuration(ticks: UInt64): string;
var
ms: Uint64;
sc: Uint64;
mn: Uint64;
begin
mn := ticks div 60000;
ticks -= mn * 60000;
sc := ticks div 1000;
ticks -= sc * 1000;
ms := ticks;
result := format('%d minutes, %d seconds and %d msecs', [mn, sc, ms]);
end;
//TODO-cfeature: make it working with relative paths
function commonFolder(const files: TStringList): string;
var

View File

@ -428,7 +428,7 @@ type
fDfmtWidg: TDfmtWidget;
fProfWidg: TProfileViewerWidget;
fCompStart: TDateTime;
fCompStart: UInt64;
fRunProjAfterCompArg: boolean;
fRunProjAfterCompile: boolean;
@ -2478,7 +2478,7 @@ procedure TMainForm.projCompiling(project: ICommonProject);
begin
fProjActionsLock := true;
if fAppliOpts.showBuildDuration and not fIsCompilingGroup then
fCompStart := Time();
fCompStart := GetTickCount64;
end;
procedure TMainForm.projCompiled(project: ICommonProject; success: boolean);
@ -2493,7 +2493,8 @@ begin
begin
if fAppliOpts.showBuildDuration then
begin
fMsgs.message('Build duration: ' + TimeToStr(Time - fCompStart), project, amcProj, amkInf);
fMsgs.message('Build duration: ' + formatTicksAsDuration(GetTickCount64 - fCompStart),
project, amcProj, amkInf);
end;
if fRunProjAfterCompile and assigned(fProject) then
begin
@ -2527,7 +2528,8 @@ begin
fMsgs.message('the project group is successfully compiled', nil, amcAll, amkInf);
if fAppliOpts.showBuildDuration then
begin
fMsgs.message('Group build duration: ' + TimeToStr(Time - fCompStart), nil, amcAll, amkInf);
fMsgs.message('Group build duration: ' + formatTicksAsDuration(GetTickCount64 - fCompStart),
nil, amcAll, amkInf);
end;
if assigned(fProjBeforeGroup) then
fProjBeforeGroup.activate;
@ -3021,6 +3023,9 @@ var
rng: TStringRange = (ptr:nil; pos:0; len: 0);
begin
if fAppliOpts.showBuildDuration then
fCompStart := GetTickCount64;
result := false;
fMsgs.clearByData(fDoc);
FreeRunnableProc;
@ -3163,6 +3168,11 @@ begin
fMsgs.message(shortenPath(fDoc.fileName, 25) + ' has not been compiled',
fDoc, amcEdit, amkErr);
end;
if fAppliOpts.showBuildDuration then
begin
fMsgs.message('Runnable build duration: ' + formatTicksAsDuration(GetTickCount64 - fCompStart),
nil, amcAll, amkInf);
end;
finally
dmdproc.Free;
@ -4274,7 +4284,7 @@ begin
fIsCompilingGroup := true;
fMsgs.message('start compiling a project group...', nil, amcAll, amkInf);
if fAppliOpts.showBuildDuration then
fCompStart := Time;
fCompStart := GetTickCount64;
for i:= 0 to fProjectGroup.projectCount-1 do
begin
fProjectGroup.getProject(i).activate;