I think GetTickCount() has worse accuracy than timeGetTime() even (perhaps also influenced by timeBeginPeriod() though).<div>Another option I use on PC's is QueryPerformanceTimer(), but I can imagine those are a bit flaky on mobile or performance-tuning machines.</div>
<div><br></div><div>Cheers,</div><div>Ruud<br><br><div class="gmail_quote">On Mon, Oct 22, 2012 at 2:51 AM, Lee Salzman <span dir="ltr"><<a href="mailto:lsalzman@gmail.com" target="_blank">lsalzman@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You can try replacing it with something like GetTickCount() in the code instead of using the timeBeginPeriod/timeGetTime stuff and see what happens... Really, I can't entirely predict how much this will break ENet's timing or not, try and see...<div class="HOEnZb">
<div class="h5"><br>
<br>
On 10/22/2012 02:58 AM, Mike Kasprzak wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
(Hey Sven)<br>
<br>
Okay, then let me give a practical example so I don't get a "you<br>
should always use 1ms" response. ;)<br>
<br>
To meet Intel's Power Certification requirements, an application must<br>
idle (not run, but idle) with a timer period 15.6 ms. Basically, if<br>
you never call "timeBeginPeriod", then you pass. timeBeginPeriod<br>
changes the ms clock rate of all running applications on Windows, and<br>
the lowest period set will always have priority. Lower timer periods<br>
across all of Windows have an effect on power drain, and that is why<br>
they care. If you're the main in-focus application it's fine, but if<br>
you're minimized, it's "not neighborly" to be forcing other<br>
applications to run at a lower timer period when they don't need to.<br>
At least, that's the best way I can think of to explain that<br>
requirement.<br>
<br>
So the practical use: A game would want to set it to 1 ms due to<br>
broken vsync and better ping, but if the game is minimized then it<br>
doesn't need such a low rate.<br>
<br>
I found calls to "timeBeginPeriod" in SDL and enet. Again, it's right<br>
there in the win32 implementation of enet_initialize.<br>
<br>
Now sure, I can just go right in to win32.c and remove it. Easy.<br>
That's not the issue.<br>
<br>
The issue is if I do that, can anyone think of a reason enet will break on me?<br>
<br>
And with that in mind, should enet be doing this all the time anyways?<br>
SDL gives you the option of building the SDL library without timer<br>
support, which is a way of disabling it.<br>
<br>
I'm totally cool with it staying as a default and all, but should<br>
there be a "proper" way of disabling it besides editing source? Then<br>
it becomes my responsibility to set the timer period on Windows as I<br>
gain/lose application focus (or not at all). I'm just hoping there's<br>
not some reason enet will suddenly start losing data because my clock<br>
updates are 15ms slow. :)<br>
<br>
Thanks,<br>
<br>
Mike Kasprzak<br>
Sykhronics Entertainment<br>
<a href="http://www.sykhronics.com" target="_blank">www.sykhronics.com</a><br>
<br>
<br>
On Sun, Oct 21, 2012 at 6:57 PM, Sven Bergström<<a href="mailto:fuzzyspoon@gmail.com" target="_blank">fuzzyspoon@gmail.com</a><u></u>>  wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
MIKE, what are you doing on my list!<br>
<br>
So, I think it's also implementation detail of the game itself, much like<br>
ruud suggests.<br>
Some games would not need lower precision, some games would.<br>
<br>
Though that doesn't mean I understand the full extent of the changes on ENet<br>
internals,<br>
it doesn't appear to (by digging around in the code) change enough to cause<br>
problems.<br>
<br>
I'd wait for lee to weigh in, though.<br>
<br>
Sven<br>
<br>
<br>
On Sun, Oct 21, 2012 at 7:49 PM, Ruud van Gaal<<a href="mailto:ruud@racer.nl" target="_blank">ruud@racer.nl</a>>  wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I would say the time accuracy has an influence on ping time, where it<br>
helps to get millsecond accuracy instead of just 15ms.<br>
Resend times are big enough to probably not be influenced much.<br>
<br>
Still, any game quickly uses 1ms timing, if only for accurate fps timing.<br>
<br>
I think ENet will run, but just a bit more jerky than is needed.<br>
<br>
Ruud<br>
<br>
<br>
On Sun, Oct 21, 2012 at 6:06 PM, Mike Kasprzak<<a href="mailto:mike@sykhronics.com" target="_blank">mike@sykhronics.com</a>><br>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I have a bit of an overly technical enet implementation question, so<br>
apologies in advance.<br>
<br>
Long story short, I've been going through and doing some work to make<br>
an older game of mine pass Intel's power use certification tests. To<br>
do that, you run Intel's Power Checker tool alongside your app/game:<br>
<br>
<br>
<a href="http://software.intel.com/en-us/software-assessment?&paneltab[tabs-28-main]=pid-252-28#pid-252-28" target="_blank">http://software.intel.com/en-<u></u>us/software-assessment?&<u></u>paneltab[tabs-28-main]=pid-<u></u>252-28#pid-252-28</a><br>

<br>
The older game is totally single player game that doesn't use<br>
networking at all. That said, I was investigating one of my fail<br>
points (timer precision) by running my new games client and server,<br>
where I noticed even the server (without any graphics at all) was also<br>
using a 1ms precision. A bunch of digging later, I found a<br>
"timeBeginPeriod (1);" call inside win32 implementation of<br>
enet_initialize.<br>
<br>
My question is: How important is timer precision to enet's overall<br>
implementation?<br>
<br>
I realize that's a vague question, so let me clarify. Raising (or not<br>
changing) the timer precision means calls to timeGetTime() will simply<br>
not return new numbers until the timer period has passed. So, if the<br>
Windows default of 15ms is used, no matter how many times you call it<br>
during those 15ms, it will not change. For reference, timeGetTime is<br>
used inside enet_time_get and enet_time_set, so that's how it affects<br>
enet.<br>
<br>
So a better question: What would a lower precision timer break in enet?<br>
<br>
Like, is the time used in any way that may delay packets? Or is it<br>
purely statistical, like it will just ruin our frame of reference on<br>
when a packet was sent/received?<br>
<br>
Thanks,<br>
<br>
Mike Kasprzak<br>
Sykhronics Entertainment<br>
<a href="http://www.sykhronics.com" target="_blank">www.sykhronics.com</a><br>
______________________________<u></u>_________________<br>
ENet-discuss mailing list<br>
<a href="mailto:ENet-discuss@cubik.org" target="_blank">ENet-discuss@cubik.org</a><br>
<a href="http://lists.cubik.org/mailman/listinfo/enet-discuss" target="_blank">http://lists.cubik.org/<u></u>mailman/listinfo/enet-discuss</a><br>
</blockquote>
<br>
<br>
______________________________<u></u>_________________<br>
ENet-discuss mailing list<br>
<a href="mailto:ENet-discuss@cubik.org" target="_blank">ENet-discuss@cubik.org</a><br>
<a href="http://lists.cubik.org/mailman/listinfo/enet-discuss" target="_blank">http://lists.cubik.org/<u></u>mailman/listinfo/enet-discuss</a><br>
<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
ENet-discuss mailing list<br>
<a href="mailto:ENet-discuss@cubik.org" target="_blank">ENet-discuss@cubik.org</a><br>
<a href="http://lists.cubik.org/mailman/listinfo/enet-discuss" target="_blank">http://lists.cubik.org/<u></u>mailman/listinfo/enet-discuss</a><br>
<br>
</blockquote>
______________________________<u></u>_________________<br>
ENet-discuss mailing list<br>
<a href="mailto:ENet-discuss@cubik.org" target="_blank">ENet-discuss@cubik.org</a><br>
<a href="http://lists.cubik.org/mailman/listinfo/enet-discuss" target="_blank">http://lists.cubik.org/<u></u>mailman/listinfo/enet-discuss</a><br>
<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
ENet-discuss mailing list<br>
<a href="mailto:ENet-discuss@cubik.org" target="_blank">ENet-discuss@cubik.org</a><br>
<a href="http://lists.cubik.org/mailman/listinfo/enet-discuss" target="_blank">http://lists.cubik.org/<u></u>mailman/listinfo/enet-discuss</a><br>
</div></div></blockquote></div><br></div>