Time processing

hi everyone
using mrtrix3,
is there a function that could give the time of processing of an entire pipeline? a single command?
thks +++
Tim

The standard Unix time command should do the trick? That’s what I normally use, at any rate…

Hi Mr Tournier
Should I put the command at both the beginning and the end of my script ?
or/and juts after the command to get its selective time ?
thanks +++
TJ

You just need to add time in front of your command, for example:

$ time mrconvert dwi.mif dwi.nii
mrconvert: [100%] copying from "dwi.mif" to "dwi.nii"

real	0m1.585s
user	0m5.368s
sys 	0m0.586s

See the link above for an explanation of what the real, user and sys times relate to.

Hi Dr Tournier
Thanks for your answer
Do you know if it would be possible to get the time of a group of several commands ?
have a good day :slight_smile:
TJ

You could group your commands into a script and then run something like:

time my_script.sh

What @cbajada said, or if you really don’t like writing scripts, you can use the curly braces to group commands:

$ time { dwidenoise dwi.mif dwi_denoised.mif; mrdegibbs dwi_denoised.mif dwi_denoised_degibbs.mif }
dwidenoise: [100%] preloading data for "dwi.mif"
dwidenoise: [100%] running MP-PCA denoising
mrdegibbs: [100%] performing Gibbs ringing removal

real	2m47.329s
user	32m15.022s
sys	0m4.178s

Note that you can break it over several lines for clarity, and also use round brackets instead of curly braces (the latter runs the commands within a sub-shell, but it’s a subtle difference). In other words, this does the same job:

$ time ( 
  dwidenoise dwi.mif dwi_denoised.mif
  mrdegibbs dwi_denoised.mif dwi_denoised_degibbs.mif 
)

Thks Dr Tournier
you rock
Tim

1 Like