Дмитрий Рыбас on Sun, 10 Sep 2023 22:45:17 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Power (^) function speed depending on argument types


Hi All,

I observe the following
? s=0.0;n=2000;for(i=1,n,s=(s+i)^(1/5));
cpu time = 4,148 ms, real time = 4,148 ms.
? s=0.0;n=2000;for(i=1,n,s=(s+i+0.0)^(1/5));
cpu time = 51 ms, real time = 51 ms.
? s=0.0;n=2000;for(i=1,n,s=(s+i)^(0.2));
cpu time = 70 ms, real time = 73 ms.
? s=0.0;n=2000;for(i=1.0,n,s=(s+i)^(1/5));
cpu time = 50 ms, real time = 49 ms.
?
Please advise why the difference in computation time is so drastic?
Variable s is always initialized as t_REAL, and power (^) function with non-integer argument(s) supposed to convert all non t_REAL arguments to t_REAL, right?
But the first execution above is 80 times slower than the second, third and fourth..
Is this normal behavior?
Regards,
Dmitry Rybas.