title: Is there a way to count the operations it took to complete a certain part of a program?
body: <p>Out of curiosity I'm trying to find out how many operations it takes for a certain method to complete.  </p>
  
  <p>More clear and concise than before:  </p>
  
  <pre><code>doThis();
  doAswell();
  doToo();
  </code></pre>
  
  <p>I want to know how many arithmetic operations, that means actual processor actions it takes to get from calling <strong>doAswell();</strong> to completing it.</p>
  
  <pre><code>private void doAswell()
  {
      int counter = 0;
      while(counter &lt; 1000)
          counter++;
  }
  </code></pre>
  
  <p>This for example taking about 2000 ALU-steps (1000 compares + 1000 increments) + some overhead for allocation of <em>counter</em>.<br>
  Obviously I am looking to do this on more complex operations(constructors, etc.), which actually take multiple ALU-steps for one operation.</p>
  
  <p>My question:<br>
  Can I at all count the operations performed between two points in a program?<br>
  And if so: How?</p>