The Computer Language
24.11 Benchmarks Game

too simple Java OpenJ9 program

source code

/* The Computer Language Benchmarks Game
   https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
*/

// mtime side-effect
import java.io.FileOutputStream;
import java.io.FileNotFoundException;

class toosimple {
public static void main(String[] args) {  
    // mtime side-effect
    try { FileOutputStream o = new FileOutputStream("./one");  
    } catch (FileNotFoundException e) { }    
    
    long n = Long.parseLong(args[0]);
    double sum = 0.0;
    double flip = -1.0;
    for (long i = 1; i <= n; i++) {    
        flip *= -1.0;        
        sum += flip / (2*i - 1);               
    }                        
    System.out.printf("%.9f\n", sum*4.0);  
    
   // mtime side-effect      
   try { FileOutputStream o = new FileOutputStream("./two");  
   } catch (FileNotFoundException e) { }      
}
}
    

notes, command-line, and program output

NOTES:
64-bit Ubuntu quad core
openjdk 23 2024-09-17
IBM Semeru Runtimebr>
Eclipse OpenJ9
(build openj9-0.47.0) 
(JIT enabled, AOT enabled)


 Sat, 21 Sep 2024 23:56:37 GMT

MAKE:
mv toosimple.openj9 toosimple.java
/opt/src/ibm-semeru-23/bin/javac -d .   toosimple.java

2.84s to complete and log all make actions

COMMAND LINE:
 /opt/src/ibm-semeru-23/bin/java -Xshareclasses -XX:SharedCacheHardLimit=200m -Xscmx60m -Xtune:virtualized   toosimple 10000000000

PROGRAM OUTPUT:
3.141592653