How to calculate the execution time of an executable file?
Since you are asking for the execution time of an executable , I am assuming that you are working in a command line environment.
On Linux , Unix , Mac OS X , etc. you can use a command line program time
to measure the execution time. Assuming your executable is named exefile.x
, you should type
time ./exefile.x
The result you get looks something like this:
real 0m0.419s
user 0m0.112s
sys 0m0.174s
In Windows, there are tools such as timeit
that measure battery life. See, for example, How do I determine when a command is running at the Windows command prompt? for more information.
Hope it helps.
PS: for an explanation real
, user
and sys
please refer to What do "real", "user" and "sys" mean in output time (1)?
source to share
tic-toc measures execution time inside matlab. If you want your executable to be able to provide this information, you could provide an input parameter to tell your program to execute the entire program between the tic-toc pair.
tic; %process toc;
Alternatively, if you want to measure it externally, then there are various parameters depending on the operating system. For example, Linux has command time
source to share