[erlang-questions] Indexed element access: array vs. erlang:element

Dimitry Golubovsky golubovsky@REDACTED
Mon Aug 25 18:49:07 CEST 2008


Just wondering why set operations are so much faster (except for fixed
size arrays)?

The result of applying *set operations is not consumed, is it? What if
you try to do anything with it (after it is returned from timer:tc)?

Could this be some internal laziness, so only function application
thunks are indeed formed, but since results are never consumed, it
does not expand any further? Or is it some optimization of the same
kind, that the compiler sees unconsumed result, and does not really
compile anything? Or even something at JIT level?

Or am I missing anything ? ;)


On  8/25/08, Joel Reymont <joelr1@REDACTED> wrote:
> 14> arr:test().
> Fixed-size array: get:     1256ns, set:     6667ns
> Extensible array: get:     1255ns, set:       22ns
> Tuple:            get:      659ns, set:        6ns
> ok
> %% 1 million
> 15> arr:test(1000000).
> Fixed-size array: get:   121881ns, set:   777067ns
> Extensible array: get:   120026ns, set:       35ns
> Tuple:            get:    66288ns, set:       40ns
> ok

Dimitry Golubovsky

Anywhere on the Web

More information about the erlang-questions mailing list