« Computing: MD5 Command-Line Utility Updated | Main | Reversing Myopia »

Sunday, September 30, 2012

Floating Point Benchmark: COBOL Added

I have posted an update to my trigonometry-intense floating point benchmark which adds COBOL to the list of languages in which the benchmark is implemented. A new release of the benchmark collection including COBOL is now available for downloading.

The COBOL benchmark was developed with the OpenCOBOL 1.1.0 compiler under Ubuntu Linux 11.04. Unfortunately, this open source implementation of COBOL does not deliver the accuracy for floating point computations the benchmark requires—results typically differ in the sixth decimal place or beyond. Since I only quote results for benchmarks which produce identical results to the 11th decimal place, timings for OpenCOBOL do not appear in the following table.

I moved the benchmark code to a Windows 7 machine on which I had installed an evaluation version of Micro Focus Visual COBOL 2010 R4 Version 1.3.00046. This compiler created a program which produced the expected results from the computation. The speed comparison was made against the C benchmark compiled with Microsoft Visual C++ 2010 Express version 10.0.30319.1 RTMRel and run on the same machine.

The relative performance of the various language implementations (with C taken as 1) is as follows. All implementations of the benchmark listed below produced identical results to the last (11th) decimal place.

Language Relative
C 1 GCC 3.2.3 -O3, Linux
Visual Basic .NET 0.866 All optimisations, Windows XP
FORTRAN 1.008 GNU Fortran (g77) 3.2.3 -O3, Linux
Pascal 1.027
Free Pascal 2.2.0 -O3, Linux
GNU Pascal 2.1 (GCC 2.95.2) -O3, Linux
Java 1.121 Sun JDK 1.5.0_04-b05, Linux
Visual Basic 6 1.132 All optimisations, Windows XP
Haskell 1.223 GHC 7.4.1-O2 -funbox-strict-fields, Linux
Ada 1.401 GNAT/GCC 3.4.4 -O3, Linux
Lisp 7.41
GNU Common Lisp 2.6.7, Compiled, Linux
GNU Common Lisp 2.6.7, Interpreted
Smalltalk 7.59 GNU Smalltalk 2.3.5, Linux
COBOL 12.5
Micro Focus Visual COBOL 2010, Windows 7
Fixed decimal instead of computational-2
Python 17.6 Python 2.3.3 -OO, Linux
Perl 23.6 Perl v5.8.0, Linux
Ruby 26.1 Ruby 1.8.3, Linux
JavaScript 27.6
Opera 8.0, Linux
Internet Explorer 6.0.2900, Windows XP
Mozilla Firefox 1.0.6, Linux
QBasic 148.3 MS-DOS QBasic 1.1, Windows XP Console

Two versions of the benchmark program were run. Both contain identical logic in the PROCEDURE DIVISION, but declare decimal variables in different ways. The first uses COMPUTATIONAL-2, which most modern COBOL implementations map into native 64 bit IEEE floating point; this program, compiled with Visual COBOL, runs 12.5 times slower than the C benchmark. The second declares these variables as fixed point decimal computational quantities, for example:

                PICTURE IS S99V9(16) VALUE IS 1.6164.

As expected, this causes a large performance hit: this edition runs 46.3 times slower than C. The numerical results of both versions are identical.

It is, of course, an act of utter gibbering lunacy to do scientific computation like this in COBOL, but it is nice to know that there are implementations of COBOL available which will do the job, if asked, albeit at a languid pace.

Posted at September 30, 2012 14:21