[erlang-questions] performance vs msg queue length

Bernard Duggan <>
Wed Apr 21 00:58:31 CEST 2010


Matthew Sackman wrote:
> 3. You are constructing ever longer lists of 'ok' atoms. Doing a
> recursive loop with counter would avoid this, and so you would get down
> to timings of doing the actual receives.
>   
I'd considered that one too, but I think the inner list comprehension
falls squarely into the "result obviously not used" category that allows
the compiler to optimise away result storage (see the optimisation guide
and a thread a month or so back discussing this).  Out of curiosity I
replaced the list comprehension with a lists:foreach() (which always
doesn't store results)and the results were actually marginally (though
not hugely) worse across the board.

6> test:comprehension().
5.0
0.6
0.24
0.295
0.1545
0.1631
0.160826
[ok,ok,ok,ok,ok,ok,ok]
7> test:foreach().
6.0
0.8
0.33
0.382
0.1846
0.1998
0.195081


Cheers,

Bernard


More information about the erlang-questions mailing list