|
[Sponsors] |
![]() |
![]() |
#1 |
Guest
Posts: n/a
|
Hi, all:
Can someone tell me how to meause CPU time in C? I am working in Unix network. Also, I would like to know the timing method of C in Linux environment. Thanks, Amingo |
|
![]() |
![]() |
![]() |
#2 |
Guest
Posts: n/a
|
A few possibilities:
clock_t times(struct tms *buffer); time_t time(time_t *tloc); hrtime_t gethrtime(void); hrtime_t gethrvtime(void); They use different timing methods. See the man pages in section 2. |
|
![]() |
![]() |
![]() |
#3 |
Guest
Posts: n/a
|
i always found that the best (and easiest) way to measure actual CPU time in unix is to use the time command. say you have a code called cfd.exe you simply enter "time cfd.exe" at the prompt and the at the conclusion of the code the OS will print a line showing the timing of the code. the man page on the time command will explain the results.
|
|
![]() |
![]() |
![]() |
#4 |
Guest
Posts: n/a
|
Hi.
Yeah, this is a very nice feature of UNIX. But when I want to measure the CPU cost of each parts of my code for further improvement, I need a some function which I can write in code. I am not sure if time(...) can be write in my code. I think it should be. Amingo |
|
![]() |
![]() |
![]() |
#5 |
Guest
Posts: n/a
|
It sounds like you are trying to profile your code. If you are working in UNIX, there are some pretty good built-in profilers. My own personal favourite is pixie, available on SGI and DEC Alpha machines, but you'll find the basic prof command anywhere. Basically, you build an instrumented executable, run it normally and then use prof to post-process the profile data that it produces.
|
|
![]() |
![]() |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Convergence moving mesh | lr103476 | OpenFOAM Running, Solving & CFD | 30 | November 19, 2007 14:09 |
cpu time. | Daniel | FLUENT | 2 | March 20, 2006 04:51 |
Adjoint CPU time | Peter | Main CFD Forum | 0 | April 18, 2003 14:21 |
How to measure CPU time in C | Amingo | Main CFD Forum | 0 | June 15, 2000 17:15 |
cpu time | Gengsheng Wei | Main CFD Forum | 1 | November 19, 1998 15:22 |