Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > high resolution time function under windows platform?

Reply
Thread Tools

high resolution time function under windows platform?

 
 
wavelet
Guest
Posts: n/a
 
      08-01-2005
Hi,

I am searching one time function under windows2000
with Visual C++ environment. Is there function available
like gethrtime() in unix? Thx.


#include <sys/time.h>

main()
{
hrtime_t start, end;
int i, iters = 100;

start = gethrtime();
for (i = 0; i < iters; i++)
getpid();
end = gethrtime();
printf("Avg getpid() time = %lld nsec\n", (end - start) / iters);
}

RGS,
Wavelet


 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      08-01-2005
wavelet wrote:
> I am searching one time function under windows2000
> with Visual C++ environment. Is there function available
> like gethrtime() in unix? Thx.
> [..]


And the reason you're asking here is...?

If you need a time function under Windows, ask in a newsgroup
for programming Windows.
 
Reply With Quote
 
 
 
 
Bill Shortall
Guest
Posts: n/a
 
      08-01-2005

"wavelet" <(E-Mail Removed)> wrote in message
news:dcllcd$(E-Mail Removed)...
> Hi,
>
> I am searching one time function under windows2000
> with Visual C++ environment. Is there function available
> like gethrtime() in unix? Thx.
>
>
> #include <sys/time.h>
>
> main()
> {
> hrtime_t start, end;
> int i, iters = 100;
>
> start = gethrtime();
> for (i = 0; i < iters; i++)
> getpid();
> end = gethrtime();
> printf("Avg getpid() time = %lld nsec\n", (end - start) / iters);
> }
>
> RGS,
> Wavelet


Hi wavellet,

Windows has a millisecond timer available if thats good enough It returns
a long. Its in <windows.h>
usage is something like
long tim;
tim = GetTickCount();
// put what you want to time in here
tim = GetTickCount() - tim;


}
>
>



 
Reply With Quote
 
Tobias Blomkvist
Guest
Posts: n/a
 
      08-01-2005
wavelet sade:
> Hi,
>
> I am searching one time function under windows2000
> with Visual C++ environment. Is there function available
> like gethrtime() in unix? Thx.
>


QueryPerformanceCounter
QueryPerformanceFrequency

Tobias
--
IMPORTANT: The contents of this email and attachments are confidential
and may be subject to legal privilege and/or protected by copyright.
Copying or communicating any part of it to others is prohibited and may
be unlawful.
 
Reply With Quote
 
velthuijsen@hotmail.com
Guest
Posts: n/a
 
      08-02-2005

> Windows has a millisecond timer available if thats good enough It returns
> a long. Its in <windows.h>
> usage is something like
> long tim;
> tim = GetTickCount();
> // put what you want to time in here
> tim = GetTickCount() - tim;
>


One caveat here. The millsecond timers in Windows do not update every
millisecond. For windows since NT 3.1 the millisecond timers update
roughly every 16 milliseconds. The 95 famliy updates roughly every 55
milliseconds.

 
Reply With Quote
 
Maett
Guest
Posts: n/a
 
      08-02-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote:

>
> One caveat here. The millsecond timers in Windows do not update every
> millisecond. For windows since NT 3.1 the millisecond timers update
> roughly every 16 milliseconds. The 95 famliy updates roughly every 55
> milliseconds.
>


You might want to look at
http://groups.google.ch/group/comp.l...c413f34baf1a7f

Greets
Maett
 
Reply With Quote
 
velthuijsen@hotmail.com
Guest
Posts: n/a
 
      08-02-2005
> You might want to look at
> http://groups.google.ch/group/comp.l...c413f34baf1a7f


What is the point you were trying to make?

 
Reply With Quote
 
Maett
Guest
Posts: n/a
 
      08-02-2005
(E-Mail Removed) <(E-Mail Removed)> wrote:

>>> One caveat here. The millsecond timers in Windows do not update every
>>> millisecond. For windows since NT 3.1 the millisecond timers update
>>> roughly every 16 milliseconds. The 95 famliy updates roughly every 55
>>> milliseconds.


>> You might want to look at
>> http://groups.google.ch/group/comp.l...c413f34baf1a7f

>
> What is the point you were trying to make?
>


Sorry if that was unclear:
I just wanted to add that the Windows millisecond timer tick depends on
your hardware (whether it's 10 ms or roughly 16 ms).
You can even vary it on certain hardware types.

Maett
 
Reply With Quote
 
Marcin Kalicinski
Guest
Posts: n/a
 
      08-04-2005
> I am searching one time function under windows2000
> with Visual C++ environment. Is there function available
> like gethrtime() in unix? Thx.


Try these:

QueryPerformanceCounter();

or

GetThreadTimes();

or the ultimate (80x86 only):

__asm __emit 0fh
__asm __emit 031h

And 64 bit result is in EDX:EAX. The unit is one cpu cycle.

cheers,
M.






 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cosine function returning long double (high resolution) ratcharit@gmail.com C Programming 11 03-06-2008 08:36 PM
Is time.time() < time.time() always true? flamesrock Python 8 11-24-2006 06:51 AM
Software that renders high resolution JPGs to same resolution AVI? HS Crow Digital Photography 11 09-23-2005 12:28 PM
high resolution time needed Uwe Mayer Python 1 02-21-2005 10:23 PM
Looking for high-end 18- or 19-inch flat panels with high resolution. KL234 Digital Photography 6 02-26-2004 08:18 PM



Advertisments