[erlang-questions] Re: Fastest pseudo-random number-generator: erlang:statistics(io) ?

Zoltan Lajos Kis kiszl@REDACTED
Tue Nov 24 17:10:19 CET 2009

> On Nov 24, 11:20 pm, Dave Smith <diz...@REDACTED> wrote:
>> Off the top of my head, I have to wonder if using statistics(io) is
>> going to yield sufficient pseudo-randomness for load distribution
>> purposes. If you consider that most IO is likely to be a block size
>> modulo 8 (for efficiency) it seems like you might get a skewed
>> distribution. A simpler (and perhaps faster) approach would be to just
>> maintain a counter that gets atomically incremented on each call -- a
>> port driver or ETS table would suffice and have similar amounts of
>> contention as the call to statistics.
> Maintaining a counter in ETS would be (much) slower, so that is
> unfortunately no option for me. I have tried some simple randomness
> tests for this io-function in the running server and the distribution
> looks sufficiently random. I have many processes sending and receiving
> data (via ports), so that shouldn't be a problem. Someone else told me
> that erlang:now() blocks the scheduler shortly, so that is something I
> definitely want to avoid.
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org

How about process_info(self(), reductions). ?


More information about the erlang-questions mailing list