Yichao,

Thanks for the response. I'm going to keep using rand() and not worry about
it. The main downside I see that is that, when analyzing code with
@code_warntype and similar, each use of rand() "pollutes" the result and
makes it harder to understand.

-- mb

On Sun, Mar 13, 2016 at 9:55 PM, Yichao Yu <yyc1...@gmail.com> wrote:

> On Sun, Mar 13, 2016 at 9:47 PM, Miguel Bazdresch <eorli...@gmail.com>
> wrote:
> > While trying to optimize some code for performance, I noticed that rand()
> > and randn() generate much more code than rand(1) and randn(1). In
> addition,
>
> It generate more code since there are more inlining.
>
> > rand() and randn() have type instabilities, easily seen with
> @code_warntype.
>
> These type instability actually doesn't matter since the result is
> never used and IIRC it is also only in the slow path.
>
> >
> > It seems to me than rand() should be faster and generate less code than
> > rand(1), because rand(1) basically means "run rand() and put the result
> in
> > an array".
> >
> > Is this a bug, or at least a place where Julia's performance could be
> > improved?
>
> The type stability could be fixed (although last time I tried it
> there's no performance impact at all).
>
> >
> > -- mb
>

Reply via email to