title: does splitting logic into multiple methods in java slows down execution? if yes then shall we avoid re-factoring of code
body: <p><a href="http://s24.postimg.org/9y073weid/refactor_vs_non_refactor.png" rel="nofollow noreferrer">http://s24.postimg.org/9y073weid/refactor_vs_non_refactor.png</a>
  <img src="https://i.stack.imgur.com/qlvzR.png" alt="enter image description here">
  Well here is the result for the execution time in nanoseconds for re-factored and non re-factored code for a simple addition operation. 1 to 5 are the consecutive runs of the code.
  My intent was just to find out whether splitting up logic into multiple methods makes execution slow or not and here is the result which shows that yes there is considerable time that goes into just putting the methods on stack.</p>
  
  <p>I invite people who have done some research on it before or want to investigate on this area to correct me if I am doing something wrong and draw some conclusive results out of this.
  In my opinion yes code re-factoring does help in making code more structured and understandable but in time critical systems like real time game engines I would prefer not to re-factor.</p>
  
  <p>Following was the simple code which I used:</p>
  
  <pre><code>    package com.sim;
  </code></pre>
  
  <p>public class NonThreadedMethodCallBenchMark{</p>
  
  <pre><code>public static void main(String args[]){
      NonThreadedMethodCallBenchMark testObject = new NonThreadedMethodCallBenchMark();
      System.out.println("************Starting***************");
      long startTime =System.nanoTime();
  
      for(int i=0;i&lt;900000;i++){
          //testObject.method(1, 2); // Uncomment this line  and comment the line below to test refactor time
          //testObject.method5(1,2); // uncomment this line and comment the above line to test non refactor time
      }
      long endTime =System.nanoTime();
      System.out.println("Total :" +(endTime-startTime)+" nanoseconds");
  }
  
  public int method(int a , int b){
      return method1(a,b);
  }
  public int method1(int a, int b){
      return method2(a,b);
  }
  public int method2(int a, int b){
      return method3(a,b);
  }
  public int method3(int a, int b){
      return method4(a,b);
  }
  public int method4(int a, int b){
      return method5(a,b);
  }
  public int method5(int a, int b){
      return a+b;
  }
  public void run() {
      int x=method(1,2);
  }
  </code></pre>
  
  <p>}</p>