-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #445 from Remi-Gau/remi-refactor_elapsed-time
[REF] refactor elapsedTime and integrate it into the code base
- Loading branch information
Showing
28 changed files
with
208 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,63 @@ | ||
function [startTime, runTime] = elapsedTime(input, startTime, runTime, nbIteration) | ||
% | ||
% USAGE:: | ||
% | ||
% [start, runTime] = elapsedTime(input, startTime, runTime, nbIteration) | ||
% | ||
% | ||
% (C) Copyright 2021 CPP_SPM developers | ||
function [startTime, runTime] = elapsedTime(opt, action, startTime, runTime, nbIteration) | ||
% | ||
% USAGE:: | ||
% | ||
% [start, runTime] = elapsedTime(input, startTime, runTime, nbIteration) | ||
% | ||
% | ||
% (C) Copyright 2021 CPP_SPM developers | ||
|
||
if nargin < 3 | ||
runTime = []; | ||
end | ||
if nargin < 4 | ||
runTime = []; | ||
end | ||
|
||
switch input | ||
switch action | ||
|
||
case 'start' | ||
case 'start' | ||
|
||
startTime = tic; | ||
startTime = tic; | ||
|
||
case 'stop' | ||
case 'stop' | ||
|
||
fprintf('\n\n********* Done :) *********\n\n'); | ||
printDone(opt); | ||
|
||
fprintf(' elapsed time is: ') | ||
t=toc(startTime(end)); | ||
disp(datestr(datenum(0,0,0,0,0,t),'HH:MM:SS')); | ||
t = toc(startTime(end)); | ||
msg = sprintf(' elapsed time: %s', formatDuration(t)); | ||
printToScreen(msg, opt); | ||
|
||
runTime(end+1) = t; | ||
ETA = mean(runTime) * (nbIteration - numel(runTime)); | ||
fprintf('\n ETA: ') | ||
disp(datestr(datenum(0,0,0,0,0,ETA),'HH:MM:SS')); | ||
runTime(end + 1) = t; | ||
ETA = mean(runTime) * (nbIteration - numel(runTime)); | ||
msg = sprintf('\n ETA: %s', formatDuration(ETA)); | ||
printToScreen(msg, opt); | ||
|
||
fprintf('\n***************************\n\n'); | ||
printHorizontalLine(opt, 27); | ||
|
||
case 'globalStart' | ||
case 'globalStart' | ||
|
||
startTime = tic; | ||
startTime = tic; | ||
|
||
case 'globalStop' | ||
case 'globalStop' | ||
|
||
fprintf('\n\n********* Pipeline done :) *********\n\n'); | ||
fprintf(' global elapsed time is: ') | ||
t=toc(startTime); | ||
disp(datestr(datenum(0,0,0,0,0,t),'HH:MM:SS')); | ||
fprintf('\n************************************\n\n'); | ||
printToScreen('\n\n********* Pipeline done :) *********\n', opt); | ||
|
||
end | ||
t = toc(opt.globalStart); | ||
msg = sprintf(' global elapsed time: %s', formatDuration(t)); | ||
printToScreen(msg, opt); | ||
|
||
printHorizontalLine(opt, 36); | ||
|
||
end | ||
|
||
end | ||
|
||
function printDone(opt) | ||
printToScreen('\n\n********* Done :) *********\n', opt); | ||
end | ||
|
||
function printHorizontalLine(opt, length) | ||
printToScreen(['\n' repmat('*', 1, length) '\n\n'], opt); | ||
end | ||
|
||
function string = formatDuration(duration) | ||
string = datestr(datenum(0, 0, 0, 0, 0, duration), 'HH:MM:SS'); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,4 +74,6 @@ function bidsCopyInputFolder(opt, unzip) | |
printToScreen('\n\n', opt); | ||
end | ||
|
||
cleanUpWorkflow(opt); | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,6 +133,9 @@ function bidsCreateROI(opt) | |
end | ||
|
||
end | ||
|
||
end | ||
|
||
cleanUpWorkflow(opt); | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,8 @@ function bidsCreateVDM(opt) | |
|
||
end | ||
|
||
cleanUpWorkflow(opt); | ||
|
||
bidsRename(opt); | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,6 @@ function bidsLesionOverlapMap(opt) | |
|
||
end | ||
|
||
cleanUpWorkflow(opt); | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,8 @@ function bidsMidbrainReslice(opt) | |
|
||
end | ||
|
||
cleanUpWorkflow(opt); | ||
|
||
bidsRename(opt); | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,8 @@ function bidsRFX(action, opt) | |
|
||
end | ||
|
||
cleanUpWorkflow(opt); | ||
|
||
end | ||
|
||
function checks(opt, action) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,4 +65,6 @@ function bidsRename(opt) | |
|
||
end | ||
|
||
cleanUpWorkflow(opt); | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,8 @@ | |
|
||
end | ||
|
||
cleanUpWorkflow(opt); | ||
|
||
cd(currentDirectory); | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,4 +40,6 @@ | |
|
||
end | ||
|
||
cleanUpWorkflow(opt); | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.