Benchmark Test Methods for "float" Operation

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

After finishing performance testing on "int" and "long" operations, I want to look at "float" and "double" operations.

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

/**
 * BenchmarkTestFloat.java
 * Copyright (c) 2010, HerongYang.com, All Rights Reserved.
 */
class BenchmarkTestFloat {

   // The empty loop benchmark test method
   public static float emptyLoop(int steps, BenchmarkRunner runner) {
      float x = 0;
      float i = 0;
      float 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 float assignment(int steps, BenchmarkRunner runner) {
      float x = 0;
      float i = 0;
      float 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 float add(int steps, BenchmarkRunner runner) {
      float x = 0;
      float i = 0;
      float last = steps;
      runner.startTimer();
      for (i=0; i<last; i+=1) {
         x = i + i;
      }
      runner.stopTimer();
      return x;
   }

   // Test method for a multiply operation in a loop
   public static float multiply(int steps, BenchmarkRunner runner) {
      float x = 0;
      float i = 0;
      float 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 float division(int steps, BenchmarkRunner runner) {
      float x = 0;
      float i = 0;
      float last = steps;
      runner.startTimer();
      for (i=0; i<last; i+=1) {
         x = i / 3;
      }
      runner.stopTimer();
      return x;
   }
}

Note that:

Last update: 2010.

Table of Contents

 About This Book

 Downloading and Installing JDK 1.8.0 on Windows

 Downloading and Installing JDK 1.7.0 on Windows

 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 28.2.7 by Oracle Corporation

 JVM Runtime Data Areas

 Memory Management and Garbage Collectors

 Garbage Collection Tests

 JVM Stack, Frame and Stack Overflow

 Thread Testing Program and Result

 CPU Impact of Multi-Thread Applications

 I/O Impact of Multi-Thread Applications

 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

 Outdated Tutorials

 References

 PDF Printing Version