Rocket jBASE

 View Only

Performance enhancement in jBASE 5.8: comparing against '' (NULL)

  • 1.  Performance enhancement in jBASE 5.8: comparing against '' (NULL)

    ROCKETEER
    Posted 05-03-2022 12:54

    In jBASE 5.8, an enhancement to the BASIC (aka jBC) compiler has made comparisons against '' (empty string) dramatically faster.

    Historically it was quicker to compare the LEN() of a variable against 0 to test if a variable was '' (NULL).

    For example if you're on 5.7 (or earlier) try the sample code.

    workVar = STR('the quick brown fox jumps over the lazy dog', 10000)
    startTime = SYSTEM(12)
    FOR I = 1 TO 10000
        IF workVar NE '' THEN
        END
    NEXT I
    CRT 'First FOR loop took: ':SYSTEM(12)-startTime
    
    startTime = SYSTEM(12)
    FOR I = 1 TO 10000
        IF LEN(workVar) THEN
        END
    NEXT I
    CRT 'Second FOR loop took: ':SYSTEM(12)-startTime
    ​

    On 5.8 the statement:

    IF workVAR NE '' THEN

    now gets compiled to a special function (this is also true for EQ '') that performs the same as

    IF LEN(workVar) NE 0 THEN

    so the sample program (above) will produce similar results (depending on system usage).



    ------------------------------
    Peter Falson
    Rocket Internal - All Brands
    ------------------------------