[erlang-questions] Optimization for the ++ operator

Björn-Egil Dahlberg wallentin.dahlberg@REDACTED
Fri Jun 1 12:07:33 CEST 2012


1 jun 2012 kl. 10:46 skrev "José Valim" <jose.valim@REDACTED>:

The '++' operator does not verify that the second argument is a list.
> Therefore, the compiler will rewrite the first expression to simply:
>
> [$F,$o,$o|Bar]
>

Yes, thanks. For some weird reason I thought Erlang restricted the right
side to be a list in such cases.


> Have you made sure that you run each test in a newly spawned process?

Do you run the test for long enough time?
>

Running in a newly spawned process did the trick, the results are now
consistent.
I was already running it 1000 times, here is the code (without using spawn):

https://www.refheap.com/paste/2954

I assume having a "clean" heap (reducing the chance of garbage collection)
is the reason why it is a good idea to run benchmarks in a newly spawned
process?


If you want to vary one parameter in a test, make sure all other parameters
stays the same otherwise you have no idea what you are measuring!

Code loading, heaps, position of mars .. Everything has to be taken into
account.



Thanks Björn!

_______________________________________________
erlang-questions mailing list
erlang-questions@REDACTED
http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120601/1b60310f/attachment.htm>


More information about the erlang-questions mailing list