By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,417 Members | 1,047 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,417 IT Pros & Developers. It's quick & easy.

How can I get microseconds in windows???

P: n/a
_F

I can include time.h and use time() to get UTC seconds,but

how can I get microseconds ??

My OS is windows.

--
>> xWjut My # ntust.org #
>> Author from: 218-35-21-103.cm.dynamic.apol.com.tw 
Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"_F" <as*******@ntust.org> wrote...

I can include time.h and use time() to get UTC seconds,but

how can I get microseconds ??

My OS is windows.


Then ask in comp.os.ms-windows.programmer. C++ language doesn't have
any microsecond-resolution functions.
Jul 22 '05 #2

P: n/a
> I can include time.h and use time() to get UTC seconds,but
how can I get microseconds ??
My OS is windows.


Your question is offtopic here, please read the FAQ at
http://www.parashift.com/c++-faq-lite before posting.

<OT>
Check out QueryPerformanceCounter() function from Windows API
</OT>

Cheers,
Marcin
Jul 22 '05 #3

P: n/a
as*******@ntust.org (?_???F) wrote in message news:<4D********@ntust.org>...
I can include time.h and use time() to get UTC seconds,but

how can I get microseconds ??

My OS is windows.


The CVS version of boost date_time has a class called microsec_clock
that allows you to write this:

using namespace boost::posix_time;
ptime t = microsec_clock::local_time();
...

On windows this uses the ftime API which will be millisecond
resolution for sure and some hardware might be micro-second. You'll
have to try it to be sure. On Unix this clock uses the GetTimeOfDay
interface which seems to reliably produce microsecond level samples.

If you want this in a released version of Boost you'll probably need
to wait a few weeks until 1.32 is released.

Jeff
Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.