<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Copy instruction cycles</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83501/copy-instruction-cycles</link><description>I tested various copy methods in terms of instruction cycles, that I determined with DWT. 
 For that I copied an uint8_t array size 70 by 
 
 for Loop --&amp;gt; 63 Cycles 
 memcpy --&amp;gt; 514 Cycles 
 std::array copy --&amp;gt; 514 Cycles 
 
 Are theses result valid?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 10 Jan 2022 13:41:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83501/copy-instruction-cycles" /><item><title>RE: Copy instruction cycles</title><link>https://devzone.nordicsemi.com/thread/346959?ContentTypeID=1</link><pubDate>Mon, 10 Jan 2022 13:41:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5444eb73-244e-4884-9f05-abbff9717440</guid><dc:creator>stackGreen</dc:creator><description>&lt;p&gt;so as far as I understood its about the context and optimization. &amp;nbsp;If I disable optimization with -O0, the &amp;ldquo;copy by for loop&amp;rdquo; cycles increased to 2129 (memcpy 828)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Copy instruction cycles</title><link>https://devzone.nordicsemi.com/thread/346869?ContentTypeID=1</link><pubDate>Mon, 10 Jan 2022 09:51:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc4d7f42-16e7-4ea3-a14f-27e08bd16483</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I would also have expected memcpy to be faster than a for loop, and I certainly did not expect it to be that much slower. Have you tried to optimize for speed as discussed in this blog post by memfault: &lt;a href="https://interrupt.memfault.com/blog/memcpy-newlib-nano"&gt;https://interrupt.memfault.com/blog/memcpy-newlib-nano&lt;/a&gt; ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>