473,396 Members | 2,087 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

timeGetTime

how come this snippet has got an output like:
12297359.000000
12297359.000000
12297375.000000
12297375.000000
12297390.000000
12297390.000000
12297406.000000
Jul 23 '05 #1
9 10698
marcus wrote:
why does it sometimes claim that no time has passed and sometimes
claim that about 16 milliseconds has past?
Because that's the *granularity* with which the system clock runs on
your machine.
It should be millisecond
Should? Who said that?
resolution on it (ok I know windows is not a realtime operating
system, but anyway I think it should do better than this I was
planning to do some profiling on my code)


Don't use it for profiling. Use something else (QueryPerformanceCounter
for example). Many systems have better ways to keep time, you just need
to research your particular system, and for that you need to post to
a newsgroup that deals with your system, comp.os.ms-windows.programmer,
in your case.
Jul 23 '05 #2
marcus wrote:

how come this snippet has got an output like:
12297359.000000
12297359.000000
12297375.000000
12297375.000000
12297390.000000
12297390.000000
12297406.000000
.
.

while (1)
printf("%f\n", timeGetTime());

why does it sometimes claim that no time has passed and sometimes
claim that about 16 milliseconds has past?
Because the time couting chip in your computer has
a resolution of 16 milliseconds only?
It should be millisecond
resolution on it
It has milliseconds resolution.
All the time values are in the unit 'milliseconds'.
But nowhere the documentation says that the value will
increase with 1 millisecond :-)
(ok I know windows is not a realtime operating
system,
'realtime operating system' has nothing to do with it.
but anyway I think it should do better than this I was
planning to do some profiling on my code)


You can do it.
Execute the code in question 16 times and divide the resulting
time by 16 and you get an accuracy of 1 millisecond. (Well
sort of, if the process didn't get swapped or interrupted
and nothing else is happening on your machine besides running
your program. You get the idea)

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 23 '05 #3
marcus wrote:

how come this snippet has got an output like:
12297359.000000
12297359.000000
12297375.000000
12297375.000000
12297390.000000
12297390.000000
12297406.000000
.
.

while (1)
printf("%f\n", timeGetTime());

why does it sometimes claim that no time has passed and sometimes
claim that about 16 milliseconds has past?
Because the time couting chip in your computer has
a resolution of 16 milliseconds only?
It should be millisecond
resolution on it
It has milliseconds resolution.
All the time values are in the unit 'milliseconds'.
But nowhere the documentation says that the value will
increase with 1 millisecond :-)
(ok I know windows is not a realtime operating
system,
'realtime operating system' has nothing to do with it.
but anyway I think it should do better than this I was
planning to do some profiling on my code)


You can do it.
Execute the code in question 16 times and divide the resulting
time by 16 and you get an accuracy of 1 millisecond. (Well
sort of, if the process didn't get swapped or interrupted
and nothing else is happening on your machine besides running
your program. You get the idea)

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 23 '05 #4
Am 19 Apr 2005 10:03:32 -0700 schrieb marcus <ma************@koping.net>:
how come this snippet has got an output like:
12297359.000000
12297359.000000
12297375.000000
12297375.000000
12297390.000000
12297390.000000
12297406.000000
.
.

while (1)
printf("%f\n", timeGetTime());

why does it sometimes claim that no time has passed and sometimes
claim that about 16 milliseconds has past? It should be millisecond
resolution on it (ok I know windows is not a realtime operating
system, but anyway I think it should do better than this I was
planning to do some profiling on my code)


The basic windows clock tick usually is 10 ms (on a PC without intel hyperthreading) or 15.625 ms (on a PC with intel hyperthreading). But since the time value you used increments in multiples of 1ms, you observe increments of 15 or 16 ms.
Jul 23 '05 #5
ma************@koping.net (marcus) writes:
how come this snippet has got an output like:
12297359.000000
12297359.000000
12297375.000000
12297375.000000
12297390.000000
12297390.000000
12297406.000000
.
.

while (1)
printf("%f\n", timeGetTime());


There is no standard C (or C++, as far as I know) function called
timeGetTime. You should ask in a newsgroup dedicated to whatever
system you're using (assuming the documentation doesn't answer your
question).

(It's probably an issue involving the underlying resolution of
whatever time information timeGetTime() accesses.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jul 23 '05 #6
marcus wrote:

why does it sometimes claim that no time has passed and sometimes
claim that about 16 milliseconds has past? It should be millisecond
resolution on it (ok I know windows is not a realtime operating
system, but anyway I think it should do better than this I was
planning to do some profiling on my code)


If you plan to measure the speed of one algorithm compared to another:

http://www.math.uwaterloo.ca/~jamuir/rdtscpm1.pdf

In my environment (Linux/gcc) the function rdtscll is located in <asm/msr.h>
I can imagine that there is something equivalent in your system.

regards marbac
Jul 23 '05 #7
In article <6Z******************@news.chello.at>, ma****@chello.at
says...

If you plan to measure the speed of one algorithm compared to another:

http://www.math.uwaterloo.ca/~jamuir/rdtscpm1.pdf

In my environment (Linux/gcc) the function rdtscll is located in <asm/msr.h>
I can imagine that there is something equivalent in your system.


Fundamentally broken on SMP systems, and perhaps dual-core as well.
This is also OT for both of these groups you have posted it to.

--
Randy Howard (2reply remove FOOBAR)
"Making it hard to do stupid things often makes it hard
to do smart ones too." -- Andrew Koenig
Jul 23 '05 #8
Randy Howard <ra*********@FOOverizonBAR.net> writes:
[RDTSC is f]undamentally broken on SMP systems, and perhaps
dual-core as well.


Not necessarily; some SMP motherboards synchronize the TSCs of all
CPUs. I would expect that multi-core CPUs would have a single shared
TSC, or individual but synchronized TSCs for each core.

DES
--
Dag-Erling Smørgrav - de*@des.no
Jul 23 '05 #9
In article <86************@xps.des.no>, de*@des.no says...
Randy Howard <ra*********@FOOverizonBAR.net> writes:
[RDTSC is f]undamentally broken on SMP systems, and perhaps
dual-core as well.
Not necessarily; some SMP motherboards synchronize the TSCs of all
CPUs.


Since not all of them do (most I've seen do not, and I've worked on
dozens of different IA32 SMP platforms), then that is worthless
information since you can not rely upon it.
I would expect that multi-core CPUs would have a single shared
TSC, or individual but synchronized TSCs for each core.


I haven't tried it on a dual-core system yet, but hopefully they
will do so. Even so, it doesn't do much good to those that
intend to rely on rdtsc for timing, as not all platforms will
work as expected.

--
Randy Howard (2reply remove FOOBAR)
"Making it hard to do stupid things often makes it hard
to do smart ones too." -- Andrew Koenig
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: marcus | last post by:
how come this snippet has got an output like: 12297359.000000 12297359.000000 12297375.000000 12297375.000000 12297390.000000 12297390.000000 12297406.000000
0
by: Richard | last post by:
Is there a managed equivalent to timeGetTime? Thanks in advance, Richard Wilder
9
by: Ripiz | last post by:
OS Windows 98 Dev-C++ Newest at the moment I'm getting this strange error cannot find -lobjc That line contains MessageBox(NULL,"Please vote for this code at PlanetSourceCode.com","I'm begging...
12
by: DumRat | last post by:
Hi, I want to know something about functions. Say I need to swap two integers frequently in my program. The ususal way will be to declare void Swap(int & , int &);
0
ADezii
by: ADezii | last post by:
If you're interested in measuring elapsed times in your Access Application, you're much better off using the timeGetTime() API Function instead of the Timer() VBA Function. There are 4 major reasons...
1
by: DumRat | last post by:
Well, the results arouse curiosity. Check out for yourselves. http://www.thescripts.com/forum/threadnav617160-2-10.html
14
meLady
by: meLady | last post by:
Hello, Here I am having a little bit confusion about how to calculate the total time of steps of a process (for example: registering a new user for a website) in MS Access: - step1: entering a...
0
ADezii
by: ADezii | last post by:
If you want to visit each item in an Array, you have two alternatives: Use a For Each..Next loop, using a Variant to retrieve each value in turn. Use a For...Next loop, looping from the Lower...
2
ADezii
by: ADezii | last post by:
If you are executing a code segment for a fixed number of iterations, always use a For...Next Loop instead of a Do...Loop, since it is significantly faster. Each pass through a Do...Loop that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.