Welcome to Soft32 Linux Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

How to measure time difference?

 
   Soft32 Home -> Linux -> App Development RSS
Next:  [PATCH]: NMI: add Intel processor 0x6f4 to NMI pe..  
Author Message
J.H.Kim

External


Since: Nov 10, 2008
Posts: 9



(Msg. 1) Posted: Thu May 28, 2009 9:20 pm
Post subject: How to measure time difference?
Archived from groups: comp>os>linux>development>apps (more info?)

Hi, everyone

I wish to measure time gap between two point
in linux program by the millisec or below.

time() function uses too big unit(sec) to use.

How can I measure the difference of time?

Thanks in advance.

Regards,

J.H.Kim
Back to top
Login to vote
Nate Eldredge

External


Since: Nov 09, 2008
Posts: 9



(Msg. 2) Posted: Thu May 28, 2009 9:20 pm
Post subject: Re: How to measure time difference? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"J.H.Kim" <frog1120.DeleteThis@gmail.com> writes:

> Hi, everyone
>
> I wish to measure time gap between two point
> in linux program by the millisec or below.
>
> time() function uses too big unit(sec) to use.
>
> How can I measure the difference of time?

gettimeofday() will get you to the nearest microsecond.
Back to top
Login to vote
Rainer Weikusat

External


Since: Apr 02, 2007
Posts: 158



(Msg. 3) Posted: Fri May 29, 2009 5:20 am
Post subject: Re: How to measure time difference? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"J.H.Kim" <frog1120.RemoveThis@gmail.com> writes:
> I wish to measure time gap between two point
> in linux program by the millisec or below.
>
> time() function uses too big unit(sec) to use.
>
> How can I measure the difference of time?

Do you want to know the wallclock time or the CPU time consumed
while the program was actually executing the code in question?
If the first, the already mentioned gettimeofday would be a solution
with the additional benefit that this is an 'old' interface (4.2BSD,
according to the FreeBSD gettimeofday(2)) and therefore, basically
available everywhere. For the second, the newer clock_gettime could be
used (and also for the first, at the expense of portability to older
systems).
Back to top
Login to vote
Arnkore

External


Since: May 30, 2009
Posts: 1



(Msg. 4) Posted: Sat May 30, 2009 4:46 am
Post subject: Re: How to measure time difference? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On May 29, 5:27 pm, Rainer Weikusat <rweiku....TakeThisOut@mssgmbh.com> wrote:
> "J.H.Kim" <frog1....TakeThisOut@gmail.com> writes:
> > I wish to measure time gap between two point
> > in linux program by the millisec or below.
>
> > time() function uses too big unit(sec) to use.
>
> > How can I measure the difference of time?
>
> Do you want to know the wallclock time or the CPU time consumed
> while the program was actually executing the code in question?
> If the first, the already mentioned gettimeofday would be a solution
> with the additional benefit that this is an 'old' interface (4.2BSD,
> according to the FreeBSD gettimeofday(2)) and therefore, basically
> available everywhere. For the second, the newer clock_gettime could be
> used (and also for the first, at the expense of portability to older
> systems).

The gettimeofday() function is provided for porting existing code. You
shouldn't use it in new code; use clock_gettime() instead.
Back to top
Login to vote
Display posts from previous:   
Related Topics:
How can i register a link protocol for browsers - I want to add an action to the system so that every time a user clicks in a link with for example ..

storing the data in ln2440 target board memory - hai.. i using the target board ln2440sbc..and linux OS.. (16Mb flash and 32Mb sdram) i have cross compiled and porte...

GTK run error - hi i had created one same application in glad interface designer with c option.the n i compiled the same after that i....

C++ -> mplayer, stdin, stdout, popen / fork / pipe... - Hello everybody. I tried to work this out on my own for about 6 hours non-stop now and I just don't get it working.......

[PATCH -mm] swsusp: Measure memory shrinking time - Make swsusp measure and print the time needed to shrink memory during the suspend. Signed-off-by: Rafael J. Wysocki..

Simple utility to measure disk random access time - And a few graphs here: http://linux.inet.hr/how_fast_is_your_disk.html Comments welcome! #define _LARGEFILE64_SOURCE ...
       Soft32 Home -> Linux -> App Development All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Categories:
 Windows
  Linux
 Mac
 PDA


[ Contact us | Terms of Service/Privacy Policy ]