| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (3 out of 14)

Comparison of Various Types of Value Assignments

This test compares these techniques for assigning values:

Changing a local variable is approximately 15 times faster than concluding an attribute and approximately eight times faster than concluding a parameter or variable. Note that when you conclude a parameter and the value changes, the results are similar to concluding an attribute. On the other hand, changing an array element takes only twice as long as changing a local variable. Also note that concluding an array element takes eight times longer than changing an array element.


Caution: Never conclude a native array element; always change native array elements.

While referencing indexed attributes is very efficient, concluding indexed attributes is not very efficient.

Inserting into the beginning or end of a list takes five times longer than changing an array element, whereas inserting into the end of a sequence (optimized case) takes only three times as long. Changing an element of a structure is slightly faster.


Note: Unless you are inserting at the end of the same sequence, the one optimized case, the efficiency of inserting at the beginning or the end of a sequence degrades significantly as the number of elements in the sequence increases.

Thus, whenever possible, use local variable, arrays, and structures for high efficiency value assignments. Always change array elements; never conclude array elements. Avoid concluding attributes, parameters, and variables, except when necessary. Use indexed attributes only when needed for fast lookup based on attribute value.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (3 out of 14)

Copyright © 1997 Gensym Corporation, Inc.