10
3
Possible Duplicate:
Measure script execution time
How would I time how long it takes for my script foo.sh
to run?
I'm looking for something akin to tic
and toc
in MATLAB.
10
3
Possible Duplicate:
Measure script execution time
How would I time how long it takes for my script foo.sh
to run?
I'm looking for something akin to tic
and toc
in MATLAB.
18
Easiest way is to use bash's integrated time
, GNU Time or another unix time
command implementation:
time ./sript.sh
If you're interested in ticks, you can approximate it with a little help from /proc/cpuinfo
.
If you want to dig deeper, have a look at strace
.
What if one wants to measure the time between multiple commands/lines? – normanius – 2019-07-10T21:52:48.793
2time is a shell keyword
– Hello71 – 2011-04-25T23:21:18.083
1@Hello71 my linux bash
does not provide a time command, it uses /usr/bin/time
. However zsh
does, as well as my solaris tcsh
. So even if it's not builtin your shell, you have a time provided by your userland as a fallback. Besides, those time commands may provide a slightly different output. – mbx – 2011-04-26T09:45:54.877
– Hello71 – 2011-04-26T20:04:29.843
@Hello71 although reserved, on that ystem which time
returns userland time instead of the reserved keyword warning – mbx – 2011-04-26T21:20:53.990
@mbx: which
never does that. I'm referring to type
. – Hello71 – 2011-04-26T21:21:50.340
@Hello71 not which
, but the shell does (zsh
and tcsh
) – mbx – 2011-04-26T21:37:09.037
4
time
can achieve this. In this case:
$ time foo.sh
1
Duplicate of http://superuser.com/questions/228801/measure-script-execution-time/228802#228802
– Wuffers – 2011-04-04T00:03:32.527have you tried wrapping your code in time {} – n0pe – 2011-04-04T00:05:45.020