How to calculate the execution time of an executable file?

Is there a way to calculate the exact execution time of an executable file?

Specifically, I am looking for a method that can be used to run an executable compiled using Matlab. I do not mean tic

, toc

.

+3


source to share


3 answers


You can always turn on

tic

      

at the beginning of the executable and then



disp(toc)

      

at the end.

+3


source


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)?

+3


source


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

+1


source







All Articles