Note that there are some explanatory texts on larger screens.

plurals
  1. POExactly how "fast" are modern CPUs?
    text
    copied!<p>When I used to program embedded systems and early 8/16-bit PCs (6502, 68K, 8086) I had a pretty good handle on exacly how long (in nanoseconds or microseconds) each instruction took to execute. Depending on family, one (or four) cycles equated to one "memory fetch", and without caches to worry about, you could guess timings based on the number of memory accesses involved.</p> <p>But with modern CPU's, I'm confused. I know they're a lot faster, but I also know that the headline gigahertz speed isn't helpful without knowing how many cycles of that clock are needed for each instruction.</p> <p>So, can anyone provide some timings for two sample instructions, on (let's say) a 2GHz Core 2 Duo. Best and worst cases (assuming nothing in cache/everything in cache) would be useful.</p> <p><strong>Instruction #1:</strong> Add one 32-bit register to a second.</p> <p><strong>Instruction #2:</strong> Move a 32-bit value from register to memory.</p> <p><strong>Edit</strong>: The reason I ask this is to try and develop a "rule-of-thumb" that would allow me to look at simple code and roughly gauge the time taken to the nearest order of magnitude. </p> <p><strong>Edit #2:</strong> Lots of answers with interesting points, but nobody (yet) has put down a figure measured in time. I appreciate there are "complications" to the question, but c'mon: If we can estimate the <a href="http://www.google.com/url?sa=t&amp;source=web&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Fmathforum.org%2Fworkshops%2Fsum96%2Finterdisc%2Fclassicfermi.html&amp;ei=sE9qSf7LBuTSjAeQpaG2Bw&amp;usg=AFQjCNF42Q4z65LsDYUtWCdbrdBHLLoC6A&amp;sig2=5dsQt_00GjpCcmae6vTDfA" rel="noreferrer">number of piano-tuners in NYC</a>, we should be able to estimate code runtimes...</p> <p>Take the following (dumb) code: </p> <pre><code>int32 sum = frigged_value(); // start timing for (int i = 0 ; i &lt; 10000; i++) { for (int j = 0 ; j &lt; 10000; j++) { sum += (i * j) } sum = sum / 1000; } // end timing </code></pre> <p>How can we <em>estimate</em> how long it will take to run... 1 femtosecond? 1 gigayear?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload