Hello,
Does anyone know how, under Windows, I can get the exact current microsecond so that I can display a time with the microsecond precision ?
Thanks!
Hello,
Does anyone know how, under Windows, I can get the exact current microsecond so that I can display a time with the microsecond precision ?
Thanks!
- The Manual said the program required Win95 or better, so I installed Linux.
- Newton was a pessimist.
- no Risk! no FuN!
Is it that you are searching?
http://msdn.microsoft.com/library/de...etfiletime.asp
Not at all... It has nothing to do with files and I need microsecond.
Sorry.
- The Manual said the program required Win95 or better, so I installed Linux.
- Newton was a pessimist.
- no Risk! no FuN!
Originally Posted by Dwarf007
There can be many ways thru which u can get time..
The include files are :
ctime.h, time.h, windows.h... they help you in extracting the current system time...
u can get time in milliseconds.. once you have that, you can extract to microseconds...
I hope this is what you wanted...
I need microseconds, milliseconds are not precise enough.Originally Posted by Kapil
What do you mean with extract to microseconds ?
- The Manual said the program required Win95 or better, so I installed Linux.
- Newton was a pessimist.
- no Risk! no FuN!
Does Windows handle microseconds at all?
I heared and read a bit, that using the following Windows API functions : QueryPerformanceFrequency() and QueryPerformanceCounter() it should do...Originally Posted by wysota
but I didn't manage to display the current microsecond under windows, therefore I was wondering if anybody here had an example or an easy way to do that.
- The Manual said the program required Win95 or better, so I installed Linux.
- Newton was a pessimist.
- no Risk! no FuN!
Are you trying to handle something with a hard real-time requirement? I've heard of extensions (patches to kernel) for Windows to do this.
Most timers (at least standard APIs) that I've used only have a resolution of 1 millisecond ... even though they may indicate a higher resolution value.
It would be hard to get higher resolutions with standard system as the internal system clock would have to tick with frequency higher than 1kHz, meaning there would need to be more than 1000 clock interrupts per second.
Linux can.
gettimeofday() is accurate to the microsecond
- The Manual said the program required Win95 or better, so I installed Linux.
- Newton was a pessimist.
- no Risk! no FuN!
Are you sure it doesn't only display in microseconds? I believe microseconds can be obtained when using hardware alarms from the real time clock, but I doubt system clock can be that accurate on its own. AFAIR modern Linux distros on i386 architecture have the clock interrupts set at 1kHz, so it would mean they can measure time with accuracy of 0.001s = 1ms. This is only my logic explanation, if someone knows better, please say so.
you mean it just gives a millisecond accurate time and the microseconds are a kind of rand() % 999 ?
- The Manual said the program required Win95 or better, so I installed Linux.
- Newton was a pessimist.
- no Risk! no FuN!
Or set to 0. But generaly yes, it might be so.Originally Posted by Dwarf007
*grumpfl*
Ok thanks.. I think I will do something like that then.. (rand() % 999)
- The Manual said the program required Win95 or better, so I installed Linux.
- Newton was a pessimist.
- no Risk! no FuN!
Why do you need microseconds anyway?
wysota: I want to do a kind of portable and accurate gettimeofday();
Here is the solution, in case someone wants to do the same one day.
No garantie on it but it seems to work.
Windows part for a portable gettimeofday():
Qt Code:
#ifdef _WIN32_ #include <windows.h> int gettimeofday( struct timeval *tv, struct timezone *tz ) { time_t rawtime; time(&rawtime); tv->tv_sec = (long)rawtime; // here starts the microsecond resolution: LARGE_INTEGER tickPerSecond; LARGE_INTEGER tick; // a point in time // get the high resolution counter's accuracy QueryPerformanceFrequency(&tickPerSecond); // what time is it ? QueryPerformanceCounter(&tick); // and here we get the current microsecond! \o/ tv->tv_usec = (tick.QuadPart % tickPerSecond.QuadPart); return 0; } #endif // _WIN32_To copy to clipboard, switch view to plain text mode
Last edited by Dwarf007; 4th April 2006 at 12:53.
- The Manual said the program required Win95 or better, so I installed Linux.
- Newton was a pessimist.
- no Risk! no FuN!
.... and here's a class using those funcs (if it's any help)
K
Bookmarks