INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

General Coding

IF, CASE, EXECUTE... Which 's Faster???? by Gaudalier
Posted: 23 Jan 02

Evolution: the meaning of 4 and 5 GL. But a High Level Programming Lenguaje NEVER will be as FAST and SMALL as ASSEMBLER Lenguaje, by many reasons. So We are Clarion Programmers: a 4 GL (Dunno if still being 3 GL) we are not responsable for the Optimization of ASSEMBLER code that finally generate Clarion in the Exe's, but for the way we use the High Lenguaje instructions.

So I make some Testing in find the Faster instruccion in CONDITIONAL STATEMENT EXECUTION ESTRUCTURES: IF, CASE, EXECUTE, CHOOSE, INLIST. These are all That I know by now.

The BenchMark is base on a 10 Options to look for (All falses), and finally select an 11 Option when there's no matching values. All inclosed in a 10,000,000 Times LOOP

Here the code:
IF ESTATEMENT

CheckinTime#  = CLOCK()
TRUELIES#     = 69
LOOP 10000000 TIMES
  IF    TRUELIES# = 1
    TRUELIES# = 1
  ELSIF TRUELIES# = 2
    TRUELIES# = 1
  ELSIF TRUELIES# = 3
    TRUELIES# = 1
  ELSIF TRUELIES# = 4
    TRUELIES# = 1
  ELSIF TRUELIES# = 5
  TRUELIES# = 1
  ELSIF TRUELIES# = 6
  TRUELIES# = 1
  ELSIF TRUELIES# = 7
  TRUELIES# = 1
  ELSIF TRUELIES# = 8
  TRUELIES# = 1
  ELSIF TRUELIES# = 9
  TRUELIES# = 1
  ELSIF TRUELIES# = 10
  TRUELIES# = 1
  ELSE
    TRUELIES# = 96
  END
END
MESSAGE('Holding: ' & CLOCK()-CheckinTime# & ' Cent/Second','First Down  !!!!!')


CASE ESTATEMENT

CheckinTime#  = CLOCK()
TRUELIES#     = 69
LOOP 10000000 TIMES
  CASE  TRUELIES#
    OF  1
    TRUELIES# = 1
    OF  2
    TRUELIES# = 2
    OF  3
    TRUELIES# = 3
    OF  4
    TRUELIES# = 4
    OF  5
    TRUELIES# = 5
    OF  6
    TRUELIES# = 6
    OF  7
    TRUELIES# = 7
    OF  8
    TRUELIES# = 8
    OF  9
    TRUELIES# = 9
    OF  10
    TRUELIES# = 10
  ELSE
    TRUELIES# = 96
  END
END
MESSAGE('Holding: ' & CLOCK()-CheckinTime# & ' Cent/Second','First Down  !!!!!')


EXECUTE ESTATEMENT

CheckinTime#  = CLOCK()
TRUELIES#     = 69
LOOP 10000000 TIMES
  EXECUTE TRUELIES#
    TRUELIES# = 1
    TRUELIES# = 2
    TRUELIES# = 3
    TRUELIES# = 4
    TRUELIES# = 5
    TRUELIES# = 6
    TRUELIES# = 7
    TRUELIES# = 8
    TRUELIES# = 9
    TRUELIES# = 10
  ELSE
    TRUELIES# = 96
  END
END
MESSAGE('Holding: ' & CLOCK()-CheckinTime# & ' Cent/Second','First Down  !!!!!')


CHOOSE ESTATEMENT

CheckinTime#  = CLOCK()
TRUELIES#     = 69
LOOP 10000000 TIMES
  TRUELIES# = CHOOSE(TRUELIES#,1,2,3,4,5,6,7,8,9,10,96)
END
MESSAGE('Holding: ' & CLOCK()-CheckinTime# & ' Cent/Second','First Down  !!!!!')


INLIST ESTATEMENT

CheckinTime#  = CLOCK()
TRUELIES#     = 69
LOOP 10000000 TIMES
  TRUELIES# = INLIST(TRUELIES#,'1','2','3','4','5','6','7','8','9','10')
  IF TRUELIES# = FALSE
    TRUELIES# = 96
  END
END
MESSAGE('Holding: ' & CLOCK()-CheckinTime# & ' Cent/Second','First Down  !!!!!')


STATS:
Time is in Hundredths of a Sec. Test was made in a Pentium III, 256 RAM & NT 4.0 WorkStation SP 6a, Using C55f ABC. (**** The Small, the Better ****)

IF      STATEMENT:  ->  35
CASE    STATEMENT:  ->  33
EXECUTE STATEMENT:  ->  36
CHOOSE  STATEMENT:  ->  8
INLIST  STATEMENT:  ->  1619

CONCLUTION:

Well, at least you're programming a FAST requiring App. like Images and Data process, the Time you save by choosing the CHOOSE statement is not trascendental matters. Finnally the way your CODE LOOKS LIKE is order to be the easiest understanding by others or to be corrected by yourself after a long time periods, is the Conditional Statement that MUST TO BE CHOOSEN.


Bye



Back to SoftVelocity: Clarion solutions FAQ Index
Back to SoftVelocity: Clarion solutions Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close