<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[GetTickCount() gibt irgendwie komische Werte zurück! Funktion zu schnell?]]></title><description><![CDATA[<p>Hallo.</p>
<p>Im Folgenden geht es ausschließlich um die GetTickCount()s.<br />
Ich will die delta Zeit für diese Funktion ausrechnen.<br />
Ich habe hier folgende Funktion:</p>
<pre><code>// WICHTIG ///
DWORD time = GetTickCount();

while(!bDone)
	{
		ReadFile(m_logFile[m_iFileId]-&gt;hFile,&amp;wcNext, sizeof(TCHAR), &amp;written, NULL);
		i++;

		if(wcNext == TEXT('\0'))
			bDone = true;

		if(szFindString[array_pos] == wcNext)
			array_pos++;						// match, TCHAR found 
		else
			array_pos = 0;					// sorry, no match. 

		if(array_pos == (len - 1))
		{
// WICHTIG ///
			for(int q=0; q&lt;1000000000;q++){

				if(q == 1000000000-1)
					timeEnd = GetTickCount();	// muss 
//bremsen, da ich sonst immer 0 für delta bekomme, weil timeEnd und time sonst 
//immer den gleichen Wert haben.
			}
			delta = timeEnd - time;
// WICHTIG Aus///
			m_logFile[m_iFileId]-&gt;iCurrFilePos = ov.Offset = (i - (len-1))*sizeof(TCHAR);
			wcNext = TEXT('\0');
			i=0;
			bDone = true;
		}

	}
</code></pre>
<p>Also:<br />
time ist die Zeit vor dem Einlaufen der while Schleife.<br />
Wenn jetzt in der While-SChleife das hier wahr ist:</p>
<pre><code>if(array_pos == (len - 1))
</code></pre>
<p>Dann bekomme ich eine zweite Zeit, nämlich dann, wenn die while-Schleife ihren Sinn erfüllt hat und einen String gefunden hat, in der Datei.</p>
<p>Jetzt bekomme ich im delta immer den Wert 0. Daraufhin habe ich das hier eingebaut:</p>
<pre><code>for(int q=0; q&lt;1000000000;q++){

				if(q == 1000000000-1)
					timeEnd = GetTickCount();	
			}
</code></pre>
<p>Und siehe da, delta hat plötzlich einen Wert.<br />
Wie kann das sein, das ich da vorher 0 rausbekommen habe?<br />
Im debugger waren die Werte von time und timeEnd auch gleich, also vor der Bremse.</p>
<p>Ich habe einen 1.9Ghz Proz.<br />
Kann es sein das die Funktion einfach zu schnell ist? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>Gruß<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/150253/gettickcount-gibt-irgendwie-komische-werte-zurück-funktion-zu-schnell</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Jul 2026 03:22:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/150253.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 14 Jun 2006 14:15:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GetTickCount() gibt irgendwie komische Werte zurück! Funktion zu schnell? on Wed, 14 Jun 2006 14:16:49 GMT]]></title><description><![CDATA[<p>Hallo.</p>
<p>Im Folgenden geht es ausschließlich um die GetTickCount()s.<br />
Ich will die delta Zeit für diese Funktion ausrechnen.<br />
Ich habe hier folgende Funktion:</p>
<pre><code>// WICHTIG ///
DWORD time = GetTickCount();

while(!bDone)
	{
		ReadFile(m_logFile[m_iFileId]-&gt;hFile,&amp;wcNext, sizeof(TCHAR), &amp;written, NULL);
		i++;

		if(wcNext == TEXT('\0'))
			bDone = true;

		if(szFindString[array_pos] == wcNext)
			array_pos++;						// match, TCHAR found 
		else
			array_pos = 0;					// sorry, no match. 

		if(array_pos == (len - 1))
		{
// WICHTIG ///
			for(int q=0; q&lt;1000000000;q++){

				if(q == 1000000000-1)
					timeEnd = GetTickCount();	// muss 
//bremsen, da ich sonst immer 0 für delta bekomme, weil timeEnd und time sonst 
//immer den gleichen Wert haben.
			}
			delta = timeEnd - time;
// WICHTIG Aus///
			m_logFile[m_iFileId]-&gt;iCurrFilePos = ov.Offset = (i - (len-1))*sizeof(TCHAR);
			wcNext = TEXT('\0');
			i=0;
			bDone = true;
		}

	}
</code></pre>
<p>Also:<br />
time ist die Zeit vor dem Einlaufen der while Schleife.<br />
Wenn jetzt in der While-SChleife das hier wahr ist:</p>
<pre><code>if(array_pos == (len - 1))
</code></pre>
<p>Dann bekomme ich eine zweite Zeit, nämlich dann, wenn die while-Schleife ihren Sinn erfüllt hat und einen String gefunden hat, in der Datei.</p>
<p>Jetzt bekomme ich im delta immer den Wert 0. Daraufhin habe ich das hier eingebaut:</p>
<pre><code>for(int q=0; q&lt;1000000000;q++){

				if(q == 1000000000-1)
					timeEnd = GetTickCount();	
			}
</code></pre>
<p>Und siehe da, delta hat plötzlich einen Wert.<br />
Wie kann das sein, das ich da vorher 0 rausbekommen habe?<br />
Im debugger waren die Werte von time und timeEnd auch gleich, also vor der Bremse.</p>
<p>Ich habe einen 1.9Ghz Proz.<br />
Kann es sein das die Funktion einfach zu schnell ist? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>Gruß<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1077651</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1077651</guid><dc:creator><![CDATA[DeineMutter]]></dc:creator><pubDate>Wed, 14 Jun 2006 14:16:49 GMT</pubDate></item><item><title><![CDATA[Reply to GetTickCount() gibt irgendwie komische Werte zurück! Funktion zu schnell? on Wed, 14 Jun 2006 14:17:11 GMT]]></title><description><![CDATA[<p>herjemine...das ist WinAPI!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1077652</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1077652</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Wed, 14 Jun 2006 14:17:11 GMT</pubDate></item><item><title><![CDATA[Reply to GetTickCount() gibt irgendwie komische Werte zurück! Funktion zu schnell? on Wed, 14 Jun 2006 14:19:56 GMT]]></title><description><![CDATA[<p>herjemine...das ist übelstes Gefrickel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1077657</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1077657</guid><dc:creator><![CDATA[-.-]]></dc:creator><pubDate>Wed, 14 Jun 2006 14:19:56 GMT</pubDate></item><item><title><![CDATA[Reply to GetTickCount() gibt irgendwie komische Werte zurück! Funktion zu schnell? on Wed, 14 Jun 2006 14:43:28 GMT]]></title><description><![CDATA[<p>Also das geht mit</p>
<pre><code>GetTickCount() * 0.001f
</code></pre>
<p>Wenn man das also in sec umrechnet, ist zwar komisch, da msec genauer sind, aber bitte.</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1077684</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1077684</guid><dc:creator><![CDATA[DeineMutter]]></dc:creator><pubDate>Wed, 14 Jun 2006 14:43:28 GMT</pubDate></item><item><title><![CDATA[Reply to GetTickCount() gibt irgendwie komische Werte zurück! Funktion zu schnell? on Wed, 14 Jun 2006 14:58:51 GMT]]></title><description><![CDATA[<p>Na wenn weniger als eine Millisekunde Zeit vergangen ist wird delta auch bei 0 bleiben.<br />
Welche Typen haben delta und timeEnd?<br />
Versuch doch mal, mit Sleep() die Schleife zu verzögern - ist delta dann noch immer 0?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1077697</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1077697</guid><dc:creator><![CDATA[Neku]]></dc:creator><pubDate>Wed, 14 Jun 2006 14:58:51 GMT</pubDate></item><item><title><![CDATA[Reply to GetTickCount() gibt irgendwie komische Werte zurück! Funktion zu schnell? on Wed, 14 Jun 2006 18:14:54 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile.php?mode=viewprofile&amp;u=10455" rel="nofollow">evilissimo</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=15" rel="nofollow">C++</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=4" rel="nofollow">WinAPI</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1077825</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1077825</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Wed, 14 Jun 2006 18:14:54 GMT</pubDate></item><item><title><![CDATA[Reply to GetTickCount() gibt irgendwie komische Werte zurück! Funktion zu schnell? on Wed, 14 Jun 2006 19:06:05 GMT]]></title><description><![CDATA[<p>GetTickCount hat eine Auflösung von 10-20 ms. Somit wirst Du bei Zeiten, die zwischen 10-20 ms liegen immer ein Delat von 0 bekommen.<br />
Um kurze Zeiten zu Messen, musst Du QueryPerformanceCounter/Frequency verwenden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1077844</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1077844</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Wed, 14 Jun 2006 19:06:05 GMT</pubDate></item></channel></rss>