title: Is there any way to count the number of instructions in java
body: <p>I want to know how many instructions my java code consumes to execute. I am looking for an api which starts the instruction count and the final total number of instructions should be returned at the end</p>
  
  <p>For example:</p>
  
  <pre><code>public static void main()
  {
    int a=0;
    int b=0;
    int c=0;
    startCountinst();
    if(a==b)
    {
       c++;
    }
    int n = stopCountinst();
  }
  </code></pre>
  
  <p>At the end, n should represent the total number of instructions executed after calling <code>startCountinst()</code>. Is it possible in java to count the instructions?</p>