update perform 1

Documentation Version for Comments and Changes

You are invited to make any changes...add any comments.

Changes will `eventually` be merged into the offical documentation.

Leave any commnents here...

...

... back to index page OE documentation



Performance Tips

General Tips

  • If your program is fast enough, forget about speeding it up. Just make it simple and readable.
  • If your program is way too slow, the tips below will probably not solve your problem. You should find a better overall algorithm.
  • The easiest way to gain a bit of speed is to turn off run-time type-checking. Insert the line:
without type_check 

at the top of your main .ex file, ahead of any include statements. You'll typically gain between 0 and 20 percent depending on the types you have defined, and the files that you are including. Most of the standard include files do some user-defined type-checking. A program that is completely without user-defined type-checking might still be speeded up slightly.
Also, be sure to remove, or comment-out, any

with trace 
with profile 
with profile_time 

statements. with trace (even without any calls to trace), and with profile can easily slow you down by 10% or more. with profile_time might slow you down by 1%. Each of these options will consume extra memory as well.

  • Calculations using integer values are faster than calculations using floating-point numbers
  • Declare variables as integer rather than atom where possible, and as sequence rather than object where possible. This usually gains you a few percent in speed.
  • In an expression involving floating-point calculations, it's usually faster to write constant numbers in floating point form, e.g. when x has a floating-point value, say, x = 9.9

    change:
x = x * 5 

to:

x = x * 5.0 

This saves the interpreter from having to convert integer 5 to floating-point 5.0 each time.

  • Euphoria does short-circuit evaluation of if, elsif, and while conditions involving and and or. Euphoria will stop evaluating any condition once it determines if the condition is true or not. For instance in the if-statement:
if x > 20 and y = 0 then 
    ... 
end if 

The "y = 0" test will only be made when "x > 20" is true.
For maximum speed, you can order your tests. Do "x > 20" first if it is more likely to be false than "y = 0".
In general, with a condition "A and B", Euphoria will not evaluate the expression B, when A is false (zero). Similarly, with a condition like "A or B", B will not be evaluated when A is true (non-zero).
Simple if-statements are highly optimized. With the current version of the interpreter,

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu