On Wed, Sep 28, 2016 at 12:32 AM, Zhilong Liu <lzl200102...@gmail.com> wrote:
> Hello all,
>
> I tried to compare two norm() computations as shown below:
>
> u = 1.; v = 1.;
>
> # case 1: constants as arguments
> @time for i = 1 : 10000
>   g = k * norm([1.; 1.])^3
> end
>
> # case 2: variables as arguments
> @time for i = 1 : 10000
>   g = k * norm([u; v])^3
> end
>
> And the computation speed in case 2 is much slower than case 1. Is there a
> way to improve this? Ideally, I would expect them to have the same speed.

Read the performance tip in the manual and don't benchmark in the global scope.

>
>
>
> Zhilong Liu
>
>
>
>
>

Reply via email to