<?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[Mehr Performance]]></title><description><![CDATA[<p>Angesteckt von <a href="http://www.c-plusplus.net/forum/322905" rel="nofollow">diesem Thread</a> wollte ich auch mal dieses Project Euler probieren.</p>
<p><a href="http://projecteuler.net/problem=1" rel="nofollow">Problem 1</a>:</p>
<p>Wie kann ich die Performance von meinem Code verbessern? Für die obere Grenze von 10000000000ull brauche ich bereits 3,26 Sekunden (lineares Laufzeitverhalten mit <code>limit</code> sowieso).</p>
<pre><code class="language-cpp">// in project euler #1: a = 3, b = 5, limit = 1000
std::uint64_t sum_multiples(std::uint64_t a, std::uint64_t b, std::uint64_t limit) {
	using namespace std;
	uint64_t result = 0;

	for (uint64_t n = 1; n * a &lt; limit; ++n) result += n * a;

	for (uint64_t n = 0, run = true; run; ++n)
		for (uint64_t x = 1; x &lt; a; ++x)
			if ((n * a + x) * b &lt; limit) result += ((n * a + x) * b);
			else run = false;

	return result;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/322910/mehr-performance</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Jul 2026 13:43:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/322910.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 11 Jan 2014 17:48:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Mehr Performance on Sat, 11 Jan 2014 17:48:21 GMT]]></title><description><![CDATA[<p>Angesteckt von <a href="http://www.c-plusplus.net/forum/322905" rel="nofollow">diesem Thread</a> wollte ich auch mal dieses Project Euler probieren.</p>
<p><a href="http://projecteuler.net/problem=1" rel="nofollow">Problem 1</a>:</p>
<p>Wie kann ich die Performance von meinem Code verbessern? Für die obere Grenze von 10000000000ull brauche ich bereits 3,26 Sekunden (lineares Laufzeitverhalten mit <code>limit</code> sowieso).</p>
<pre><code class="language-cpp">// in project euler #1: a = 3, b = 5, limit = 1000
std::uint64_t sum_multiples(std::uint64_t a, std::uint64_t b, std::uint64_t limit) {
	using namespace std;
	uint64_t result = 0;

	for (uint64_t n = 1; n * a &lt; limit; ++n) result += n * a;

	for (uint64_t n = 0, run = true; run; ++n)
		for (uint64_t x = 1; x &lt; a; ++x)
			if ((n * a + x) * b &lt; limit) result += ((n * a + x) * b);
			else run = false;

	return result;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2376720</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2376720</guid><dc:creator><![CDATA[Troll_]]></dc:creator><pubDate>Sat, 11 Jan 2014 17:48:21 GMT</pubDate></item><item><title><![CDATA[Reply to Mehr Performance on Sat, 11 Jan 2014 18:03:10 GMT]]></title><description><![CDATA[<blockquote>
<p>Every language has an optimization operator. In C++ that operator is ‘//’</p>
</blockquote>
<p>:p</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2376725</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2376725</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Sat, 11 Jan 2014 18:03:10 GMT</pubDate></item><item><title><![CDATA[Reply to Mehr Performance on Sat, 11 Jan 2014 18:16:24 GMT]]></title><description><![CDATA[<p>Wieviele durch 3 teilbare zahlen gibt es denn bis 1000? Genau 1000/3 (abgerundet) = 333, und was ist deren Summe? Genau 3*(1+2+...+333) = 3*333*334/2.</p>
<p>Analog für 5. Die durch 15 teilbaren wurden doppelt gezählt, müssen also noch abgezogenw werden. Ergibt insgesamt konstante laufzeit, wir brauchen nichtmal ne schleife.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2376729</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2376729</guid><dc:creator><![CDATA[Jester]]></dc:creator><pubDate>Sat, 11 Jan 2014 18:16:24 GMT</pubDate></item><item><title><![CDATA[Reply to Mehr Performance on Sat, 11 Jan 2014 18:34:06 GMT]]></title><description><![CDATA[<p>obvious troll is obvious.</p>
<p>akzeptiere halt dass nicht jeder so gut im bezug auf mathematik / programmierung ist und sich trotzdem in dem forum meldet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2376737</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2376737</guid><dc:creator><![CDATA[Fytch]]></dc:creator><pubDate>Sat, 11 Jan 2014 18:34:06 GMT</pubDate></item></channel></rss>