# Thread: time.h and miliseconds question

1. ## time.h and miliseconds question

using time.h seems to want to only give me seconds. Anyone know how to grab the time in miliseconds? Is there anything else that has more presision (sp?)?

2. XP VC 6.0

also it's a win32 api program
if winblows has anthing like that.

whatever happened to getting the raw value of the system clock? that sucker was in miliseconds, and a firggin huge number at that.

Why OS btw?

3. well, lemme tell you my problem, and hopefully you can suggest something.

I want to only preform an operation after 30 miliseconds. I have the theory drawn out where I would get the time, then do a loop and compare that time with the current time. When the difference is > 30 miliseconds exit loop.

Code:
```variable1
variable2

variable1 = getTimeInMiliseconds;
variable2 = getTimeInMiliseconds;
while (variabe1 - variable2 > 30) {
//loop
variable2 = getTimeInMiliseconds;
}```

4. GetTickCount

Certainly available in VC++.

5. if absolute precision is the name of the game GetTickCount may not be the best choice. Let me warn that more precision = moreoverhead, i.e it takes longer for the function to return a value

look into
timeGetTime
and
timeGetSystemTime (this is, i believe, the most accurate and precise)

this gives a good explanation how to increase precision

6. >Let me warn that more precision = moreoverhead, i.e it takes longer for the function to return a value

Although I'm going to argue about which method is best, but surely the longer it takes for the function to return, the less accurate it's going to be. I.e.

Code:
```// I need the time NOW!
DWORD now = timeGetTime(); // But this takes ages to return```
This reminds me of Heisenbergs Uncertainty Principle.

7. Although I'm going to argue about which method is best, but surely the longer it takes for the function to return, the less accurate it's going to be. I.e.

code:--------------------------------------------------------------------------------
// I need the time NOW!
DWORD now = timeGetTime(); // But this takes ages to return
--------------------------------------------------------------------------------
No need to argue, if you say you know which ones is best please say so, I was just trying to say the basics and point to a valid resource, but im sure you know which is better Davros

This reminds me of Heisenbergs Uncertainty Principle.
This I'll start a fuss over, time isn't a particle getting moved by the energy transferred from photons of light when they collide

Do you know how to use the timeBeginTime and timeEndTime and query performance functions to increase accuracy? I read over it somewhat but all the information automatically fell out of my head.

8. >No need to argue, if you say you know which ones is best please say so

I'm not going to argue because I don't know. I'm up for a discussion on this - if you want, but not an argument.

I was just picking up on a point you made. If you say method X is much more accurate than method Y, but method X takes much longer to return, then method X can't be particularly accurate. (Not unless the time it takes to return is known precisely, which would be doubtful.)

>This I'll start a fuss over, time isn't a particle getting moved by the energy transferred from photons of light when they collide

Mmmm. I was simply making an analogy.

Hands up all those who have a degree in Physics.

9. I was just picking up on a point you made. If you say method X is much more accurate than method Y, but method X takes much longer to return, then method X can't be particularly accurate. (Not unless the time it takes to return is known precisely, which would be doubtful.)
Now that I think about it that way, that is a good point, however it is true that the more accurate time function takes longer, that is what it says on msdn, so it must be true!

Maybe we should develop a rule then:
If you need something that needs to calculate time many times (i.e frames per second per game) then use the slightly less accurate method (it hardly matters because in this case it only needs to determine if it is over 1000ms, so a small inaccuracy could only result in incorrectly report only a few frames.

If however, you need something that doesn't need to be calculated many times per second, but needs absolute accuracy and precision, then go for the more accurate and precise methods that generate more overhead. I can't think of something that would require that much precision.

Mmmm. I was simply making an analogy.

Hands up all those who have a degree in Physics.
sorry, I'm an ass

10. >sorry, I'm an ass

Not true. You almost had me digging through physics text books.

11. Not true. You almost had me digging through physics text books.
maybe I should be a motivational speaker or something

Hmm I wonder if we've helped Diamonds @ all lol