CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Main CFD Forum

How to measure CPU time in C

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   June 15, 2000, 17:15
Default How to measure CPU time in C
  #1
Amingo
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
  Reply With Quote

Old   June 16, 2000, 04:01
Default Re: How to measure CPU time in C
  #2
andy
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.
  Reply With Quote

Old   June 16, 2000, 15:13
Default Re: How to measure CPU time in C
  #3
clifford bradford
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.
  Reply With Quote

Old   June 16, 2000, 22:26
Default Re: How to measure CPU time in C
  #4
Amingo
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
  Reply With Quote

Old   June 19, 2000, 05:07
Default Re: How to measure CPU time in C
  #5
Steve Amphlett
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.
  Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convergence moving mesh lr103476 OpenFOAM Running, Solving & CFD 30 November 19, 2007 15:09
cpu time. Daniel FLUENT 2 March 20, 2006 05: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 16:22


All times are GMT -4. The time now is 12:56.