Created On:  28 November 2012

Problem:

Customer was converting a Net Express native application to a Visual COBOL managed code application and noticed that there was an extreme performance hit when executing a COMPUTE statement that included fractional exponentiation.

Program looked like:

01

ws.
   05 WS-TEST-VALUE PIC S9(9)V9(4) COMP-3.
   05 WS-TEST-INTEREST PIC S9V9(6) COMP-3.
   05 WS-NO-DAYS PIC S9(05) COMP-3.
   05 WS-DAYS-BET-ANIV PIC S9(05) COMP-3.

   MOVE

44406.25 TO WS-TEST-VALUE.
   MOVE 0.015 TO WS-TEST-INTEREST.
   MOVE 365 TO WS-NO-DAYS.
   MOVE 365 TO WS-DAYS-BET-ANIV.

   COMPUTE
WS-TEST-VALUE ROUNDED = WS-TEST-VALUE * ((1 + WS-TEST-INTEREST) ** (WS-NO-DAYS / WS-DAYS-BET-ANIV)).

The Compute statement above was taking about 20+ seconds to execute.

How can this performance be increased?

Resolution:

The problem is that in managed code COMP-3 data types do not map directly to a managed code .NET data type so a lot of conversion is done "under-the-covers".

A fix was made beginning in Visual COBOL 2.1 Update 1 to increase the speed of this process overall.

In addition a new compiler directrive has been added, ILEXPONENTIATION(FLOAT) which will direct the compiler to generate .NET native floating-point data items for each of the COMP-3 data items being used which will greatly improve the performance.

Default setting for ILEXPONENTIATION is (DECIMAL) in order to be compatible with older releases.
Incident #2595775