Cubes Benchmark

The Cubes game can be run as a benchmark. This can optionally be done with graphical output disabled so that the processing time needed to display the animation can be factored out of the execution time.

The version that can do this is here.

And the sources are here.

Included in the above are versions of Cubes written in Java, and Scala, for comparison with CAL. The Java version is written in a typical OO style, and the Scala version is written in a typical FP style (e.g. no Scala "var"s are used).

Various timing are taken between the generation of each frame of the cubes animation. The basic sequence is:

  1. Get the start time.
  2. Calculate all the polygons for the next frame.
  3. Optionally display them.
  4. Get the end time, and hence know the processing time.
  5. Calculate how long to wait before the next frame should be generated.
  6. Sleep for that time.
  7. Repeat the process.
The sleep calculation is based upon the start time of the benchmark as a whole plus the correct number of time periods (frames) multiplied by the specified delay between each frame. Doing it this way should eliminate any time "creep" in the basic processing loop (i.e. each frame should produced exactly at the correct time).

Running the benchmark is done as follows:

java [options] -jar cubes3.jar [language]

Where language is either:

And the options are:

A typical run might be:

java -Dhse.graphics.ticktime=10 -Dhse.graphics.printticks=5 -Dhse.graphics.display=0 -jar cubes3.jar java

The benchmark will repeat until it is terminated with Ctrl-C.

Results

Each run of the benchmark produces three numbers. These are millisecond times with 6 decimal places giving them nanosecond accuracy. These numbers are:
  1. The average frame time achieved.
  2. The average time sleeping.
  3. The average time processing.

The first number should equal the sum of the second two. In practice a 1 ns difference often occurs which is probably due to a nanosecond rollover occurring somewhere in the benchmark processing code. An error message is displayed if the difference is not 0 or 1 ns,

The following results were obtained on a 2 GHz Athlon 64 3200+


M:\jars>java -Dhse.graphics.frametime=10 -Dhse.graphics.printtime=5 -Dhse.graphics.display=0 -jar cubes3.jar java
The frame time in ms is = 10.000000
Print frame count = 500
Displaying = false
[10.000927:9.137308:0.863618]
[10.001239:9.583913:0.417325]
[10.001420:9.592373:0.409047]
[10.001434:9.554762:0.446671]
[10.001483:9.557219:0.444264]
[10.001385:9.578321:0.423063]
[10.001437:9.582132:0.419304]
[10.001406:9.567107:0.434298]
[10.003747:9.547868:0.455879]
[10.001095:9.550305:0.450790]

M:\jars>java -Dhse.graphics.frametime=10 -Dhse.graphics.printtime=5 -Dhse.graphics.display=0 -jar cubes3.jar scala
The frame time in ms is = 10.000000
Print frame count = 500
Displaying = false
[9.999247:8.575566:1.423680]
[9.999545:9.221754:0.777791]
[9.999490:9.188447:0.811043]
[9.999407:9.212009:0.787397]
[9.999544:9.221398:0.778145]
[9.999474:9.246745:0.752728]
[9.999428:9.219771:0.779656]
[9.999496:9.214618:0.784878]
[9.999471:9.255190:0.744280]
[10.001442:9.255183:0.746258]

M:\jars>java -Dhse.graphics.frametime=10 -Dhse.graphics.printtime=5 -Dhse.graphics.display=0 -jar cubes3.jar cal
The frame time in ms is = 10.000000
Print frame count = 500
Displaying = false
[11.083005:0.000000:11.083005]
[10.002741:2.071878:7.930862]
[10.004958:2.151614:7.853343]
[10.002760:2.055139:7.947620]
[10.002419:1.917638:8.084781]
[10.000455:2.040118:7.960337]
[10.005376:1.968004:8.037371]
[10.001393:2.027359:7.974033]
[9.999504:2.106548:7.892955]
[10.005863:2.017812:7.988050]

M:\jars>
	
Taking the fastest time for each language the results above appear to show that the Java version is fastest, with the Scala version being about 1.85 times slower, and the CAL version being about 19.85 times slower.

Contact

Nik Shaylor