<?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[Zeitmessung mit Clock]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich würde gerne zur Performancezwecken messen, wie lange mein Programm für eine bestimmte Aufgabe braucht.</p>
<p>Das habe ich derzeit so gelöst (in Anlehnung an <a href="http://www.willemer.de/informatik/cpp/timelib.htm" rel="nofollow">http://www.willemer.de/informatik/cpp/timelib.htm</a> ganz unten):</p>
<pre><code class="language-cpp">#include &lt;time.h&gt;
..
clock_t start,end;
start = clock();
//do something
end = clock();
double totaltime = difftime(end,start);
</code></pre>
<p>Also Ausgabe erhalte ich:<br />
the programm required 3170000.000000 seconds</p>
<p>Das ist natürlich Blödsinn. Wenn dann schon 3,17. Das könnte ev. passen.<br />
Hier wird aber deutlich gesagt, dass difftime die Differenz in Sekunden umrechnet: <a href="http://www.cppreference.com/wiki/c/date/difftime?s%5B%5D=difftime" rel="nofollow">http://www.cppreference.com/wiki/c/date/difftime?s[]=difftime</a></p>
<p>Was also läuft falsch?</p>
<p>Herzlichen Dank,<br />
Anna</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/242053/zeitmessung-mit-clock</link><generator>RSS for Node</generator><lastBuildDate>Mon, 21 Sep 2026 05:06:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/242053.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 29 May 2009 11:29:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Zeitmessung mit Clock on Fri, 29 May 2009 11:29:17 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich würde gerne zur Performancezwecken messen, wie lange mein Programm für eine bestimmte Aufgabe braucht.</p>
<p>Das habe ich derzeit so gelöst (in Anlehnung an <a href="http://www.willemer.de/informatik/cpp/timelib.htm" rel="nofollow">http://www.willemer.de/informatik/cpp/timelib.htm</a> ganz unten):</p>
<pre><code class="language-cpp">#include &lt;time.h&gt;
..
clock_t start,end;
start = clock();
//do something
end = clock();
double totaltime = difftime(end,start);
</code></pre>
<p>Also Ausgabe erhalte ich:<br />
the programm required 3170000.000000 seconds</p>
<p>Das ist natürlich Blödsinn. Wenn dann schon 3,17. Das könnte ev. passen.<br />
Hier wird aber deutlich gesagt, dass difftime die Differenz in Sekunden umrechnet: <a href="http://www.cppreference.com/wiki/c/date/difftime?s%5B%5D=difftime" rel="nofollow">http://www.cppreference.com/wiki/c/date/difftime?s[]=difftime</a></p>
<p>Was also läuft falsch?</p>
<p>Herzlichen Dank,<br />
Anna</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1717852</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1717852</guid><dc:creator><![CDATA[AnnaS]]></dc:creator><pubDate>Fri, 29 May 2009 11:29:17 GMT</pubDate></item><item><title><![CDATA[Reply to Zeitmessung mit Clock on Fri, 29 May 2009 11:35:24 GMT]]></title><description><![CDATA[<p>Clock liefert keine Sekunden:<br />
<a href="http://www.cplusplus.com/reference/clibrary/ctime/clock/" rel="nofollow">clock()</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1717859</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1717859</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Fri, 29 May 2009 11:35:24 GMT</pubDate></item><item><title><![CDATA[Reply to Zeitmessung mit Clock on Fri, 29 May 2009 12:27:30 GMT]]></title><description><![CDATA[<p>richtig, aber so wie ich es verstehe tut es difftime.<br />
oder muss ich das auch noch druch clocks_per_sec teilen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1717899</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1717899</guid><dc:creator><![CDATA[AnnaS]]></dc:creator><pubDate>Fri, 29 May 2009 12:27:30 GMT</pubDate></item><item><title><![CDATA[Reply to Zeitmessung mit Clock on Fri, 29 May 2009 12:33:49 GMT]]></title><description><![CDATA[<p>Tipp: wenn es nicht nur Standard-C++ sein muss und du zufällig unter Windows programmierst, kannst du auch QueryPerformanceCounter benutzen (ist recht genau).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1717902</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1717902</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Fri, 29 May 2009 12:33:49 GMT</pubDate></item><item><title><![CDATA[Reply to Zeitmessung mit Clock on Fri, 29 May 2009 12:52:15 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ja, davon habe ich gehört.<br />
Ich programmiere jedoch unter Linux.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1717918</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1717918</guid><dc:creator><![CDATA[AnnaS]]></dc:creator><pubDate>Fri, 29 May 2009 12:52:15 GMT</pubDate></item><item><title><![CDATA[Reply to Zeitmessung mit Clock on Fri, 29 May 2009 12:55:56 GMT]]></title><description><![CDATA[<p><a href="http://dell5.ma.utexas.edu/cgi-bin/man-cgi?gettimeofday" rel="nofollow">http://dell5.ma.utexas.edu/cgi-bin/man-cgi?gettimeofday</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1717922</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1717922</guid><dc:creator><![CDATA[C++Fan 2009]]></dc:creator><pubDate>Fri, 29 May 2009 12:55:56 GMT</pubDate></item><item><title><![CDATA[Reply to Zeitmessung mit Clock on Fri, 29 May 2009 13:05:58 GMT]]></title><description><![CDATA[<p>hallo!</p>
<p>Wenn ich durch CLOCKS_PER_SEC teile kommen vernünftige Sachen raus.<br />
Wieso schlagt ihr mir denn andere Funktionen vor? Ist clock() nicht so geeignet?<br />
Auf der Seite hier: <a href="http://www.willemer.de/informatik/cpp/timelib.htm" rel="nofollow">http://www.willemer.de/informatik/cpp/timelib.htm</a><br />
klingt es so, als wäre clock für Perfomancemessungen gerade gut.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1717933</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1717933</guid><dc:creator><![CDATA[AnnaS]]></dc:creator><pubDate>Fri, 29 May 2009 13:05:58 GMT</pubDate></item><item><title><![CDATA[Reply to Zeitmessung mit Clock on Fri, 29 May 2009 13:11:36 GMT]]></title><description><![CDATA[<p>AnnaS schrieb:</p>
<blockquote>
<p>richtig, aber so wie ich es verstehe tut es difftime.<br />
oder muss ich das auch noch durch clocks_per_sec teilen?</p>
</blockquote>
<p>difftime erwartet Werte vom Typ time_t und clock liefert clock_t. Kann sein, dass das ineinander konvertierbare Werte (z.B: beide long) sind, aber Ihre Bedeutung ist eine andere.<br />
Zum Thema <a href="http://www.c-plusplus.net/forum/viewtopic-var-p-is-911259.html#911259" rel="nofollow">Zeitmessung siehe hier</a>.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1717939</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1717939</guid><dc:creator><![CDATA[Werner_logoff]]></dc:creator><pubDate>Fri, 29 May 2009 13:11:36 GMT</pubDate></item></channel></rss>