<?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[Was ist am schnellste?]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe 4 Terme, die nur vom float t abhängen. Die sehen in etwa so aus:</p>
<pre><code class="language-cpp">float term1 = 3*t*t*t + 2*t+t - t;
float term2 = 6*t*t*t - 4*t*t*t ... usw.
</code></pre>
<p>Ich habe also mehrmals ein t^3, t^4 und t^2. Meine Frage: Wird der Code schneller, wenn ich die Funktion pow() benutze? Die sollte ja gut optimiert sein, aber durch die ganzen Funktionsaufrufe wird der Vorteil ja vllt wieder zerstört?<br />
Oder wäre der Code schneller, wenn ich die t^3, t^4 einmal vorberechne und dann wiederverwende?<br />
Also sowas: float f1 = t*t*t;<br />
term1 = 3<em>f1 + ...<br />
term2 = 5</em>f1 + ...</p>
<p>Was ist am schnellsten? Vorberechnung, pow() oder einfach die t*t*t lassen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/241283/was-ist-am-schnellste</link><generator>RSS for Node</generator><lastBuildDate>Mon, 21 Sep 2026 13:08:51 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/241283.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 18 May 2009 16:07:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Was ist am schnellste? on Mon, 18 May 2009 16:07:31 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe 4 Terme, die nur vom float t abhängen. Die sehen in etwa so aus:</p>
<pre><code class="language-cpp">float term1 = 3*t*t*t + 2*t+t - t;
float term2 = 6*t*t*t - 4*t*t*t ... usw.
</code></pre>
<p>Ich habe also mehrmals ein t^3, t^4 und t^2. Meine Frage: Wird der Code schneller, wenn ich die Funktion pow() benutze? Die sollte ja gut optimiert sein, aber durch die ganzen Funktionsaufrufe wird der Vorteil ja vllt wieder zerstört?<br />
Oder wäre der Code schneller, wenn ich die t^3, t^4 einmal vorberechne und dann wiederverwende?<br />
Also sowas: float f1 = t*t*t;<br />
term1 = 3<em>f1 + ...<br />
term2 = 5</em>f1 + ...</p>
<p>Was ist am schnellsten? Vorberechnung, pow() oder einfach die t*t*t lassen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712326</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712326</guid><dc:creator><![CDATA[schneller]]></dc:creator><pubDate>Mon, 18 May 2009 16:07:31 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Mon, 18 May 2009 16:14:49 GMT]]></title><description><![CDATA[<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> Horner-Schema</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712333</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712333</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Mon, 18 May 2009 16:14:49 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Mon, 18 May 2009 16:30:41 GMT]]></title><description><![CDATA[<p>Wenn du es genau wissen willst, dann benutz einen Profiler. Der Unterschied zwischen den verschiedenen Möglichkeiten hängt von zu vielen Faktoren ab, um eine allgemeingültige Antwort zu geben. Meine Vorhersage ist aber, dass (wenn dein Compiler auch nur irgendwas taugt) alles (fast) gleich schnell sein wird, denn die Werte werden einmal berechnet werden und danach immer wieder das alte Ergebnis benutzt werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712338</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712338</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 18 May 2009 16:30:41 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Mon, 18 May 2009 16:43:05 GMT]]></title><description><![CDATA[<p>Horner-Schema statt Profiler.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712344</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712344</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Mon, 18 May 2009 16:43:05 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Mon, 18 May 2009 18:42:43 GMT]]></title><description><![CDATA[<blockquote>
<p>Oder wäre der Code schneller, wenn ich die t^3, t^4 einmal vorberechne und dann wiederverwende?</p>
</blockquote>
<p>Genau das.<br />
Wenn t konstant ist - sonst geht das ja wohl nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712416</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712416</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Mon, 18 May 2009 18:42:43 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Mon, 18 May 2009 18:47:36 GMT]]></title><description><![CDATA[<p>Und wahrscheinlich noch schneller, wenn du höhere Potenzen aus tieferen berechnest. Also t^4 = (t<sup>2)</sup>2 und so weiter.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712418</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712418</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Mon, 18 May 2009 18:47:36 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Tue, 19 May 2009 00:30:52 GMT]]></title><description><![CDATA[<p>Wenns vorberechnet ist, denke ich, kann man auf sowas gut verzichten.<br />
Ein paar Nanosekunden bei der Initialisierung sparen... ich weiss nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712542</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712542</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Tue, 19 May 2009 00:30:52 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Tue, 19 May 2009 05:10:40 GMT]]></title><description><![CDATA[<p>Danke für alle Tipps!</p>
<p>Also t ist der einzige Parameter der Funktion, quasi: float foo(float t) { ... }</p>
<p>Einer hat vorgeschlagen, dass ich es mit einem Profiler testen soll. Leider kenne ich mich da überhaupt nicht aus. Kann mir jemand einen guten und einsteigerfreundlichen Profiler für C++ (ich benutze Visual Studio 05, falls das ne Rolle spielt) empfehlen?</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712553</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712553</guid><dc:creator><![CDATA[schneller]]></dc:creator><pubDate>Tue, 19 May 2009 05:10:40 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Tue, 19 May 2009 05:13:12 GMT]]></title><description><![CDATA[<p>schneller schrieb:</p>
<blockquote>
<p>Einer hat vorgeschlagen, dass ich es mit einem Profiler testen soll. Leider kenne ich mich da überhaupt nicht aus. Kann mir jemand einen guten und einsteigerfreundlichen Profiler für C++ (ich benutze Visual Studio 05, falls das ne Rolle spielt) empfehlen?</p>
</blockquote>
<p>Wenn du einen AMD-Prozessor hast, ist AMD CodeAnalyst sehr zu empfehlen. Allerdings sind solche Mikrooptimierungen nicht immer ganz einfach zu profilen, ich würde mich da eher auf grössere Bottlenecks konzentrieren. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712554</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712554</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Tue, 19 May 2009 05:13:12 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Tue, 19 May 2009 07:35:35 GMT]]></title><description><![CDATA[<p>zeig mal den bisherigen code.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712597</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712597</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Tue, 19 May 2009 07:35:35 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Tue, 19 May 2009 14:50:39 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>zeig mal den bisherigen code.</p>
</blockquote>
<p>So sieht der Code aus:</p>
<pre><code class="language-cpp">D3DXVECTOR3 HermiteCurve::interpolate(float t) const { 
   assert(t&gt;=0 &amp;&amp; t&lt;=1);

   float bf_1 = 2*t*t*t - 3*t*t + 1;  // blending function 1
   float bf_2 = -2*t*t*t + 3*t*t;
   float bf_3 = t*t*t - 2*t*t + t;
   float bf_4 = t*t*t - t*t;
   return bf_1 * p1 + bf_2 * p2 + bf_3 * r1 + bf_4 * r2;
}
</code></pre>
<p>Leider habe ich keinen AMD Prozessor, sondern einen Intel Core2Duo. Welchen Profiler nimmt man da am besten?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712847</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712847</guid><dc:creator><![CDATA[schneller]]></dc:creator><pubDate>Tue, 19 May 2009 14:50:39 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Tue, 19 May 2009 15:09:03 GMT]]></title><description><![CDATA[<p>spantan würde mir so ein gefummel einfallen.</p>
<pre><code class="language-cpp">D3DXVECTOR3 HermiteCurve::interpolate(float t) const { 
   assert(t&gt;=0 &amp;&amp; t&lt;=1);
   float t2=t*t;
   float t3=t*t*t;

   float bf_4 = t3 - t2; // t3 - t2
   float tmp_1 = bf_4 - t2; // t3 - 2*t2
   float bf_3 = tmp_1 + t; // t3 - 2*t2 + t;
   float tmp_2 = tmp_1 + t3 - t2; // 2*t3 - 3*t2;
   float bf_2 = -tmp_2; // -2*t*t*t + 3*t*t;
   float bf_1 = tmp_2 + 1; // 2*t*t*t - 3*t*t + 1 // blending function 1

   return bf_1 * p1 + bf_2 * p2 + bf_3 * r1 + bf_4 * r2;
}
</code></pre>
<p>aber keine ahnung, ob das schneller oder langsamer ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712854</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712854</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Tue, 19 May 2009 15:09:03 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Tue, 19 May 2009 18:09:17 GMT]]></title><description><![CDATA[<p>schneller schrieb:</p>
<blockquote>
<p>Leider habe ich keinen AMD Prozessor, sondern einen Intel Core2Duo. Welchen Profiler nimmt man da am besten?</p>
</blockquote>
<p>Nur um Zeit zu messen, brauchst du keinen Profiler. Da reichen dir auch betriebssystemabhängige Funktionen. Leider kenne ich mich mit denen zu wenig aus, da ich bisher immer plattformunabhängige Implementierungen innerhalb von Bibliotheken (z.B. SFML) verwendet habe.</p>
<p>Aber wie gesagt: Mikrooptimierungen sind nicht einfach zu profilen. Die Unterschiede zwischen den Messungen sind oft recht klein und können auch von vielen anderen Faktoren abhängen, zum Beispiel wie ausgelastet der Prozessor gerade ist. Wenn du ein wenig von Assembler verstehst, könntest du dir auch das kompilierte Programm anschauen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712929</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712929</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Tue, 19 May 2009 18:09:17 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Tue, 19 May 2009 19:47:04 GMT]]></title><description><![CDATA[<p>darf man mal fragen wie du ohne profiles drauf gekommen bist, dass es genau die interpolate funktion viel zeit in deinem programm braucht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712976</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712976</guid><dc:creator><![CDATA[amrande]]></dc:creator><pubDate>Tue, 19 May 2009 19:47:04 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Tue, 19 May 2009 19:54:32 GMT]]></title><description><![CDATA[<p>amrande schrieb:</p>
<blockquote>
<p>darf man mal fragen wie du ohne profiles drauf gekommen bist, dass es genau die interpolate funktion viel zeit in deinem programm braucht?</p>
</blockquote>
<p>Seinen Ausgangspost habe ich jetzt eher als allgemeine Frage aufgefasst...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712982</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712982</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Tue, 19 May 2009 19:54:32 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Wed, 20 May 2009 09:01:45 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;windows.h&gt;

using namespace std;

int main() {
LARGE_INTEGER start_ticks, ende_ticks, frequenz;

double tick_diff     = 0;
start_ticks.QuadPart = 0;
ende_ticks.QuadPart  = 0;

nochmal:

cin.get();

QueryPerformanceCounter(&amp;start_ticks);
QueryPerformanceFrequency(&amp;frequenz);

for (int i = 0; i &lt; 80000000; ++i) {
// ... hier deinen code testen ob er lahm oder schnell ist ...
}

// ... Ende der Geschwindigkeits-Tests!

QueryPerformanceCounter(&amp;ende_ticks);

tick_diff = ((double) ende_ticks.QuadPart - (double) start_ticks.QuadPart) / frequenz.QuadPart;
cout &lt;&lt; tick_diff &lt;&lt; endl;
goto nochmal;
</code></pre>
<p>hinweis: nur auf release testen. debug gibt ganz andere ergebnisse</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1713171</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1713171</guid><dc:creator><![CDATA[xBlackKnightx]]></dc:creator><pubDate>Wed, 20 May 2009 09:01:45 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Wed, 20 May 2009 16:40:26 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">nochmal: 
// ...
goto nochmal;
</code></pre>
<p>Wieso das? Hier könnte man wirklich ohne Probleme eine Schleife verwenden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1713424</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1713424</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Wed, 20 May 2009 16:40:26 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Wed, 20 May 2009 17:04:50 GMT]]></title><description><![CDATA[<p>Nexus schrieb:</p>
<blockquote>
<pre><code class="language-cpp">nochmal: 
// ...
goto nochmal;
</code></pre>
<p>Wieso das? Hier könnte man wirklich ohne Probleme eine Schleife verwenden.</p>
</blockquote>
<p>Endlosschleife, ohne goto - sehr schön! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1713443</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1713443</guid><dc:creator><![CDATA[Alter Schwede]]></dc:creator><pubDate>Wed, 20 May 2009 17:04:50 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Wed, 20 May 2009 17:09:14 GMT]]></title><description><![CDATA[<p>Alter Schwede schrieb:</p>
<blockquote>
<p>Endlosschleife, ohne goto - sehr schön! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
</blockquote>
<p>Normalerweise hat die Schleife eine Abbruchbedingung.</p>
<p>Und ja, eine Endlosschleife ist immer noch besser als <code>goto</code> , da weiss man wenigstens, was passiert. Man hat einen separaten Block mit eigenem Gültigkeitsbereich und kann das Verhalten des Programms überblicken. Es gibt schon wenige berechtigte Anwendungsbereiche für <code>goto</code> , aber sicher nicht in Situationen, in denen eine Schleife nur Vorteile hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1713445</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1713445</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Wed, 20 May 2009 17:09:14 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Wed, 20 May 2009 17:28:19 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/12954">@Nexus</a><br />
<strong>goto</strong> gehoert zur Sprache - und es bereichert sie**.** <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1713454</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1713454</guid><dc:creator><![CDATA[Alter Schwede]]></dc:creator><pubDate>Wed, 20 May 2009 17:28:19 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Wed, 20 May 2009 17:33:58 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">for  (;;)
{
 /*...*/
}
</code></pre>
<p>ist viel hübscher als goto und labels...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1713461</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1713461</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Wed, 20 May 2009 17:33:58 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Wed, 20 May 2009 18:12:48 GMT]]></title><description><![CDATA[<p>Alter Schwede schrieb:</p>
<blockquote>
<p><strong>goto</strong> gehoert zur Sprache - und es bereichert sie**.** <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
</blockquote>
<p>Natürlich. Nebenbei gehören sowohl Casts von konstanten Klasseninstanzen zu Non-Const-Referenzen auf <code>double</code> -Arrays als auch Zeiger mit siebenfacher Indirektion ebenfalls zur Sprache. Ich hoffe, du siehst den Punkt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1713481</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1713481</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Wed, 20 May 2009 18:12:48 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Thu, 21 May 2009 01:28:26 GMT]]></title><description><![CDATA[<p>xBlackKnightx schrieb:</p>
<blockquote>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;windows.h&gt;

using namespace std;

int main() {
LARGE_INTEGER start_ticks, ende_ticks, frequenz;

double tick_diff     = 0;
start_ticks.QuadPart = 0;
ende_ticks.QuadPart  = 0;

nochmal:

cin.get();

QueryPerformanceCounter(&amp;start_ticks);
QueryPerformanceFrequency(&amp;frequenz);

for (int i = 0; i &lt; 80000000; ++i) {
// ... hier deinen code testen ob er lahm oder schnell ist ...
}

// ... Ende der Geschwindigkeits-Tests!

QueryPerformanceCounter(&amp;ende_ticks);

tick_diff = ((double) ende_ticks.QuadPart - (double) start_ticks.QuadPart) / frequenz.QuadPart;
cout &lt;&lt; tick_diff &lt;&lt; endl;
goto nochmal;
</code></pre>
<p>hinweis: nur auf release testen. debug gibt ganz andere ergebnisse</p>
</blockquote>
<p>Damit misst du schnell Mist.</p>
<p>Der &quot;hier deinen code testen&quot; Bereich muss nämlich so ausgelegt sein, dass der Compiler ihn nicht wegoptimieren kann (ein paar Berechnungen, deren Ergebnis dann nirgends verwendet wird, sind nämlich im Release ganz schnell einfach nichtmehr da). Und auch keine Optimierungen vornehmen, die unter realen Einsatzbedingungen nichtmehr möglich wären. Aber auch keine &quot;nicht-wegoptimier&quot; Hilfskonstrukte enthält, die zuviel Optimierungen verhindern, oder einfach selbst zuviel Overhead machen.</p>
<p>Profilen ist eben nicht so einfach wie klein Erna sich das vorstellt.</p>
<p>Zum &quot;richtig&quot; Profilen muss man das fertige Programm profilen. Oder zumindest ausreichend grosse Programmabschnitte. Und das geht oft nur vernünftig ... mit einem Profiler <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1713587</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1713587</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Thu, 21 May 2009 01:28:26 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Thu, 21 May 2009 02:08:54 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>Zum &quot;richtig&quot; Profilen muss man das fertige Programm profilen. Oder zumindest ausreichend grosse Programmabschnitte. Und das geht oft nur vernünftig ... mit einem Profiler <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
</blockquote>
<p>Und sag jetzt blos nicht alles andere wäre prem..opt..., sonst löscht dich volkard aus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1713591</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1713591</guid><dc:creator><![CDATA[fsda]]></dc:creator><pubDate>Thu, 21 May 2009 02:08:54 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Thu, 21 May 2009 09:02:44 GMT]]></title><description><![CDATA[<p>na gut das</p>
<pre><code class="language-cpp">&quot;for (;;)&quot;
</code></pre>
<p>wird übernommen!</p>
<p>hustbaer schrieb:</p>
<blockquote>
<p>Damit misst du schnell Mist.</p>
<p>Der &quot;hier deinen code testen&quot; Bereich muss nämlich so ausgelegt sein, dass der Compiler ihn nicht wegoptimieren kann (ein paar Berechnungen, deren Ergebnis dann nirgends verwendet wird, sind nämlich im Release ganz schnell einfach nichtmehr da). Und auch keine Optimierungen vornehmen, die unter realen Einsatzbedingungen nichtmehr möglich wären. Aber auch keine &quot;nicht-wegoptimier&quot; Hilfskonstrukte enthält, die zuviel Optimierungen verhindern, oder einfach selbst zuviel Overhead machen.</p>
<p>Profilen ist eben nicht so einfach wie klein Erna sich das vorstellt.</p>
<p>Zum &quot;richtig&quot; Profilen muss man das fertige Programm profilen. Oder zumindest ausreichend grosse Programmabschnitte. Und das geht oft nur vernünftig ... mit einem Profiler <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
</blockquote>
<p>naja das mag stimmen. Ich weiss nur nicht wie Compiler das wirklich &quot;optimiert&quot;</p>
<p>wenn ich die 3 hier teste</p>
<pre><code class="language-cpp">void strcpy1( char s1[], char s2[])
{
	int i;
	for( i = 0; s2[i] != '\0'; ++i)
		s1[i] = s2[i];
	s1[i] = '\0';
}

void strcpy2( char *s1, char *s2)
{
	for( ; *s2 != '\0'; ++s1, ++s2)
		*s1 = *s2;
	*s1 = '\0';
}

void strcpy3( char *s1, char *s2)
{
	while( (*s1++ = *s2++) != '\0' );
}
</code></pre>
<p>und dann noch ein normales strcpy testen. Ergebnis: strcpy1 geht bei mir am schnellsten. Warum optimiert der Compiler nicht so dass die anderen mindestens genauso schnell sind wie strcpy1 ? Vlt mag das auch von CPU abhängen. Man kann auch da gleich ganze Programmabschnitte in &quot;hier deinen code testen&quot; einfügen oder? Oder verschiedene Funktionen zusammenstellen, die ein Programm braucht, dann immer wieder in einer bestimmten Abfolge testen lassen. Die Abfolge wird durch die externe Datei bestimmt (heisst auf Deutsch ääh z.b. 3D-Weltdaten laden und die Funktionen für Vektoren, Perspektive usw berechnen werden in Geschwindigkeitstest gemessen.) - praktisch wie ein Benchmark, somit kann man sicherstellen, dass da nix optimiert wird, wenn unterschiedliche Weltdaten geladen werden. Aber gut ich gebe zu, ich habe so ein Profiler noch nie ausprobiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1713632</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1713632</guid><dc:creator><![CDATA[xBlackKnightx]]></dc:creator><pubDate>Thu, 21 May 2009 09:02:44 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist am schnellste? on Thu, 21 May 2009 09:20:48 GMT]]></title><description><![CDATA[<p>Konnte man sich den optimierten Code nicht nochmal ausgeben lassen? Wenn ja, wie? Würde mich mal interessieren wie der verschiedene Codezeilen zerbröselt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1713639</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1713639</guid><dc:creator><![CDATA[Skalli]]></dc:creator><pubDate>Thu, 21 May 2009 09:20:48 GMT</pubDate></item></channel></rss>