CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   How to calculate CPU time in Linux system? (https://www.cfd-online.com/Forums/main/1849-how-calculate-cpu-time-linux-system.html)

HS Dou February 22, 2000 01:58

How to calculate CPU time in Linux system?
 
Hi,Everyone:

I am a new user of Linux system. Could anyone please tell me how to calculate excutive CPU time of a program in Linux system?

Before in Unix system, we use "mclock()."

Thanks in advance.

HS Dou

kang February 22, 2000 10:19

Re: How to calculate CPU time in NT system?
 
I am thinking about the same question, but on NT platform. Any information would be appreciated.

Sanjeev Kumar February 22, 2000 10:20

Re: How to calculate CPU time in Linux system?
 
You can use a command called "time" for that purpose.

clifford bradford February 22, 2000 10:29

Re: How to calculate CPU time in Linux system?
 
there should be some kind of 'time' command use the man pages. also most unix systems including linux have extensive profiling tools to let you see which subroutines in your code take most time and i think they can do things like calculate flops etc.

Bernard Parent February 22, 2000 11:55

Re: How to calculate CPU time in Linux system?
 
Use /usr/bin/time and then follow it by the name of your executable. I suggest not to use the shell built-in time function which you will invoke if you call 'time' instead of '/usr/bin/time'.

When your code will be done, the time will be outputted to stderr. Also note that this will only work if your code is non-threaded. For a threaded application (multi-CPU), there is sadly no way AFAIK to tell the CPU time on linux..

If you run your code in the background and want stdout and stderr redirected to files, here's what to type in at the bash prompt:

/usr/bin/time yourcode > scr.stdout 2> scr.stderr &

where 'yourcode' is the name of your executable.. The time required for execution will be outputted to scr.stderr, which should look something like:

72.13user 0.11system 1:16.13elapsed 94%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (5956major+626minor)pagefaults 0swaps

The first number preceding user is the number of CPU seconds the code required for completion.

have fun,

-bern

Marcio Aredes Martins February 22, 2000 21:59

Re: How to calculate CPU time in NT system?
 
If you are a fortran user (Dec, Absoft or Microsoft) use the function called TIMEF(). This function calculate the CPU time in double precision.

HS Dou March 1, 2000 23:38

Thanks very much for below help.
 
Thanks very much for below help.


All times are GMT -4. The time now is 17:30.