Package mikera.vectorz.performance

Source Code of mikera.vectorz.performance.FunctionOverheadBenchmark

package mikera.vectorz.performance;

import com.google.caliper.Runner;
import com.google.caliper.SimpleBenchmark;

/**
* Caliper based benchmarks
*
* @author Mike
*/

public class FunctionOverheadBenchmark extends SimpleBenchmark {
  volatile long temp=0;
 
  public void timeDirectOperation(int runs) {
    long t=0;
    for (int i=0; i<runs; i++) {
      for (long j=0; j<100; j++) {
        t+=j+1;
      }
    }
    temp=t;
  }
 
  public static long incFn(long j) {
    return j+1;
  }
 
  public void timeFunctionOperation(int runs) {
    long t=0;
    for (int i=0; i<runs; i++) {
      for (long j=0; j<100; j++) {
        t+=incFn(j);
      }
    }
    temp=t;
  }
 
  /**
   * @param args
   */
  public static void main(String[] args) {
    new FunctionOverheadBenchmark().run();
  }

  void run() {
    Runner runner=new Runner();
    runner.run(new String[] {this.getClass().getCanonicalName()});
  }

}
TOP

Related Classes of mikera.vectorz.performance.FunctionOverheadBenchmark

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.