Benchmarking Java Operations with Processing 2.0a5


Operations are categorized by what data type is returned or created. Operations were performed on static arrays of (1024*1024) elements. Each operation was performed (1024*1024*1024) times on a single core of an Intel Core i5 processor.

Element Arrays were created in groups of (1024*1024) elements.

Operations on the double type made use of the java.lang.Math.* methods.

Example of a test:

long Float_Sqrt(int n, int reps) {  
  float[] testArray = new float[n];  
  long startTime = System.nanoTime();
  for (int rep = 0; rep < reps; rep++) {
    for (int i = 0; i < n; i++) {
      testArray[i] = sqrt((float)i);
    }
  }
  long estimatedTime = (System.nanoTime() - startTime);    
  return estimatedTime;
}

Leave a Reply