473,725 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 10722
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 (QueryPerforman ceCounter
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.program mer,
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_Keit h) 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.che llo.at>, ma****@chello.a t
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*********@FO OverizonBAR.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*********@FO OverizonBAR.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
949
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
2676
by: Richard | last post by:
Is there a managed equivalent to timeGetTime? Thanks in advance, Richard Wilder
9
5871
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 you!",NULL); And here's all int int InitGL(void){
12
6546
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
23784
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 for this decision: __1. timeGetTime() is more accurate. The Timer() Function measure time in 'seconds' since Midnight in a single-precision floating-point value, and is not terribly accurate. timeGetTime() returns the number of 'milliseconds' that...
1
1537
by: DumRat | last post by:
Well, the results arouse curiosity. Check out for yourselves. http://www.thescripts.com/forum/threadnav617160-2-10.html
14
9898
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 user name in a text box will take 00:00:10,94 - step2: entering a user password in a text box will take 00:00:03,12 - step3: entering a user confirmation password will take 00:01:30,16 - step4: entering a user email address in a text box will take...
0
24170
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 Bound to the Upper Bound of the Array. For Each...Next seems simpler because you need not worry about retrieving the Lower and Upper Bounds- the loop takes care of that for you. For Each varValue In alngValues j = varValue Next varValue...
2
19311
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 iterates a specified number of times, requires you to also implement or decrement some sort of Loop Counter, while a For...Next Loop does that work for you. Both Loops will provide the same results, but the For...Next Loop is substantially faster. One...
0
8751
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9171
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9108
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8093
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4514
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4781
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3218
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2155
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.