Function Performance

GregTomkins

Active Member
10.2B on HP-UX

Code:
DEF VAR h_longchar AS LONGCHAR NO-UNDO.
DEF VAR h_longchar2 AS LONGCHAR NO-UNDO.
def var h_ct as int no-undo.
 
FUNCTION f RETURNS CHAR ( p_str AS CHAR ): END.
 
FUNCTION noconv RETURNS CHAR ( p_str AS CHAR ):
    RETURN p_str.
END.
 
DO h_ct = 1 TO 100:
    h_longchar = h_longchar + FILL( "a", 1000 ).
END.
 
DO h_ct = 1 TO LENGTH( h_longchar ):
    h_longchar2 = h_longchar2 + noconv( STRING( SUBSTR( h_longchar, h_ct, 1) )).
END.

We were running tests on this code and noticed that the elapsed time is significantly and consistently longer (about twice as long) when 'f' is removed and all other conditions are the same.

I realize that calling 'noconv' 100,000 times and concatenating to a LONGCHAR is sketchy, and about alternatives such as using MEMPTR and PUT-BYTES etc.

That said, any thoughts why removing a function that is both empty and unused would have any effect at all, let alone a negative effect?
 
No idea about why the unused function should have any effect, but be careful with bulk updates to the longchar, see Abe's excellent blog entry on the subject https://blog.abevoelker.com/introducing_bigcharacter/

We store intermediate results in a character and flush this to the longchar when the character becomes larger than 8 or 16k.

Just performed a quick test (11.2.1 32-bit on Win7 x64) - I see no time difference with / without the function.
 
Back
Top