O$4 vs O$3 performance

Bastiaan Olij lists at basenlily.nl
Wed Apr 29 20:54:58 EDT 2009

Hi Mary,

Using "Calculate lvRow as iBookingsList.[j]" may be useful as well or
simply making sure that the current line in iBookingsList is the line
you want to modify and then just sending the list as the parameter.
Since you are using a field reference all actions will be on the current
line of that list and there is no unnecessary copying of data.

The reason why passing iBookingsList.[j] is slow is because Omnis has
the most difficult time keeping a reference to an individual row in the
list and will be copying the entire row in and out of the list on every
access. This type of access is very unnatural to Omnis as it does not
have any internal equivalent to a reference to an individual row in a list.
Why this worked faster in OS3 I'm not sure, I do know that OS3 was
unbelievably unstable doing this sort of thing so this may well be the
result of fixing stability problems at the cost of performance.

If the list is really large it also helps showing the OO police the door.
Begin reversible block
  Set current list iBookingsList
  Calculate #L as #L ;; make sure the current line is set to what it was
when we are done
end reversible block
For each line in list
End For
Can be loads faster.

Even doing:
Calculate lvLineCount as iBookingsList.$linecount()
For j from 1 to lvLineCount step 1
End For
Can improve speed lots.

What you need to realize is that $linecount is a method call and every
time the for loop executes the method call is executed. Relatively
speaking that has far more overhead then directly accessing a variable.
The old 'for each line in list' command is even faster because it does
all the evaluations much more effectively. Its the price we pay for
using an interpreted language.

Keep that in mind always in loops, whenever you do things through
notation you get a performance penalty as in the background, it is
treated as a method call with all the accompanying overhead. Accessing a
variable directly is always faster, access often can be tokenised
speeding things up even more.

Kindest Regards,

Bastiaan Olij

More information about the omnisdev-en mailing list