Getting system time with hight precision
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Getting system time with hight precision




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Getting system time with hight precision  
Leigh Sharpe


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-26-07 06:36 AM

Hi all,
Is there any way of getting the system time, right down to the microsecond,
or even millisecond?

I need to do something a little like this:

int start_time=getTheTimeSomehow();     // Get the current time
doSomethingElse();                                 // Go and do something
else.
int end_time=getTheTimeSomehow()      // What's the time now?
int elapsed_time=end_time-start_time;     // How long did it take?

And I need to know the time as accurately as possible.


I would expect there to be a function somewhere, but I just don't know
where.








[ Post a follow-up to this message ]



    Re: Getting system time with hight precision  
Logan Shaw


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-26-07 06:36 AM

Leigh Sharpe wrote:
>  Is there any way of getting the system time, right down to the microsecon
d,
> or even millisecond?

gettimeofday() is one such method.

- Logan





[ Post a follow-up to this message ]



    Re: Getting system time with hight precision  
FrenKy


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-26-07 01:20 PM

Leigh Sharpe wrote:
> Hi all,
>  Is there any way of getting the system time, right down to the microsecon
d,
> or even millisecond?
>
> I need to do something a little like this:
>
> int start_time=getTheTimeSomehow();     // Get the current time
> doSomethingElse();                                 // Go and do something
> else.
> int end_time=getTheTimeSomehow()      // What's the time now?
> int elapsed_time=end_time-start_time;     // How long did it take?
>
> And I need to know the time as accurately as possible.
>
>
> I would expect there to be a function somewhere, but I just don't know
> where.
>
>
>

gettimeofday()?





[ Post a follow-up to this message ]



    Re: Getting system time with hight precision  
the_edge123.nospam@club-internet.fr


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-26-07 01:20 PM

On 26 mar, 08:30, Logan Shaw <lshaw-use...@austin.rr.com> wrote:
> Leigh Sharpe wrote: 
>
> gettimeofday() is one such method.
>
>    - Logan
clock_gettime is intended to go down to the nanoseconds.






[ Post a follow-up to this message ]



    Re: Getting system time with hight precision  
Frank Cusack


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-26-07 01:20 PM

On Mon, 26 Mar 2007 15:40:04 +1000 "Leigh Sharpe" <lsharpe@pacificwireless.com.au> wrote:[vb
col=seagreen]
> And I need to know the time as accurately as possible.[/vbcol]

gethrtime() on Solaris.  clock_gettime() on others.
-frank





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 07:47 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register