JVM Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 4.10

Benchmark Test Methods for "double" Operation

This section provides a list of benchmark test methods for 'double' operations that can be called by my BenchmarkRunner.java program.

Here are my test methods for "double" operations ready to be called by my BenchmarkRunner.java program:

/**
 * BenchmarkTestDouble.java
 * Copyright (c) 2010 by Dr. Herong Yang, herongyang.com
 */
class BenchmarkTestDouble {

   // The empty loop benchmark test method
   public static double emptyLoop(int steps, BenchmarkRunner runner) {
      double x = 0;
      double i = 0;
      double last = steps;
      runner.startTimer();
      for (i=0; i<last; i+=1) {
      }
      runner.stopTimer();
      x = i;
      return x;
   }

   // Test method for an assignment operation in a loop
   public static double assignment(int steps, BenchmarkRunner runner) {
      double x = 0;
      double i = 0;
      double last = steps;
      runner.startTimer();
      for (i=0; i<last; i+=1) {
         x = i;
      }
      runner.stopTimer();
      return x;
   }

   // Test method for an add operation in a loop
   public static double add(int steps, BenchmarkRunner runner) {
      double x = 0;
      double i = 0;
      double last = steps;
      runner.startTimer();
      for (i=0; i<last; i+=1) {
         x = i + 3;
      }
      runner.stopTimer();
      return x;
   }

   // Test method for a multiply operation in a loop
   public static double multiply(int steps, BenchmarkRunner runner) {
      double x = 0;
      double i = 0;
      double last = steps;
      runner.startTimer();
      for (i=0; i<last; i+=1) {
         x = i * 3;
      }
      runner.stopTimer();
      return x;
   }

   // Test method for a division operation in a loop
   public static double division(int steps, BenchmarkRunner runner) {
      double x = 0;
      double i = 0;
      double last = steps;
      runner.startTimer();
      for (i=0; i<last; i+=1) {
         x = i / 3;
      }
      runner.stopTimer();
      return x;
   }
}

Note that:

  • I used "double" data type for the loop index variable and all other variables.
  • I did not include any test method for the shift operation.

Last update: 2010.

Table of Contents

 About This Book

 Download and Install Java SE 1.6 Update 2

 java.lang.Runtime Class - The JVM Instance

 java.lang.System Class - The Operating System

 ClassLoader Class - Class Loaders

 Class Class - Class Reflections

 Sun's JVM - Java HotSpot VM

 JRockit JVM 7.0 by BEA Systems

 JRockit JVM 8.0 by BEA Systems

 Memory Management Rules and Tests

 Garbage Collection Tests

 Stack Overflow Tests

 Thread Testing Program and Result

 StringBuffer Testing Program and Result

 CDS (Class Data Sharing)

 Micro Benchmark Runner and JVM Options

 Micro Benchmark Tests on "int" Operations

 Micro Benchmark Tests on "long" Operations

 Micro Benchmark Tests in JIT Compilation Mode

Micro Benchmark Tests on "float" and "double" Operations

 Benchmark Test Methods for "float" Operation

 "float" Operations without JIT Compilation

 "float" Operations with JIT Compilation

Benchmark Test Methods for "double" Operation

 "double" Operations without JIT Compilation

 "double" Operations with JIT Compilation

 Performance Improvements of JIT Compilation

 References

 PDF Printing Version

Dr. Herong Yang, updated in 2010
Benchmark Test Methods for "double" Operation