Connecting Tech Pros Worldwide Help | Site Map

milliseconds on win+linux

  #1  
Old July 23rd, 2005, 04:57 AM
Andreas Müller
Guest
 
Posts: n/a
I need a time function like gettimeofday() (for milliseconds) that works
on both, win and linux.
I also need the value of it in a char array, I even don't know how to
convert it from gettimeofday()...
can anybody help me?

I need it for a timestamping function that marks a packet on a windows
system with a timestamp. On the Linux client I need this timestamp to
compute some stuff.
  #2  
Old July 23rd, 2005, 04:57 AM
velthuijsen@hotmail.com
Guest
 
Posts: n/a

re: milliseconds on win+linux


try the header ctime it is defined as a standard header file and as
such has the best chances of getting everyting you want.
And even then you might have to build your own functions out of the std
ones. Seeing that they only way you can get milliseconds out of the
system is by using clock() and that only counts from when the process
started (that calls clock()).
For the rest there are no shared functions for time AFAIK.

  #3  
Old July 23rd, 2005, 04:57 AM
wittempj@hotmail.com
Guest
 
Posts: n/a

re: milliseconds on win+linux


a quick example for ctime functions is here:
http://www.cplusplus.com/ref/ctime/asctime.html

  #4  
Old July 23rd, 2005, 04:57 AM
wittempj@hotmail.com
Guest
 
Posts: n/a

re: milliseconds on win+linux


a quick example for ctime functions is here:
http://www.cplusplus.com/ref/ctime/asctime.html

  #5  
Old July 23rd, 2005, 04:57 AM
osmium
Guest
 
Posts: n/a

re: milliseconds on win+linux


"Andreas Müller" writes:
[color=blue]
>I need a time function like gettimeofday() (for milliseconds) that works on
>both, win and linux.
> I also need the value of it in a char array, I even don't know how to
> convert it from gettimeofday()...
> can anybody help me?
>
> I need it for a timestamping function that marks a packet on a windows
> system with a timestamp. On the Linux client I need this timestamp to
> compute some stuff.[/color]

As far as I know you will have to attack this as two separate problems. How
to get a millisecond time stamp from Windows. How to get a millisecond time
stamp from Linux. Then when you compile, include the appropriate code. I
would browse the newsgroups for Linux and Windows for an answer already
posted, after all it is a thing a lot of people want to do.


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collecting different execution statistics of C++ programs romixnews@googlemail.com answers 17 April 13th, 2006 08:55 AM