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. // Converts all leading whites to tabs. Fails if width doesn't fivide number of spaces.
function leadingSpacesToTabs(const value: string; width: integer): string; 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 var
// additional directories to find background tools // additional directories to find background tools
additionalPath: string; additionalPath: string;
@ -1106,6 +1109,20 @@ begin
end; end;
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 //TODO-cfeature: make it working with relative paths
function commonFolder(const files: TStringList): string; function commonFolder(const files: TStringList): string;
var var

View File

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