Dear developers and users,

I noticed that an attempt to address the cycle variable heavily depends on the use of dollar sign. Consider the following file:
<hansl> #Code for DFtaumu.inp
# Dickey---Fuller's tau_mu distribution
set stopwatch
nulldata 10000
scalar T = 100
scalar tranches=10
scalar iters=10000
matrix y = zeros(T,1)
matrix DFtaumu = zeros(iters,1)
matrix RES
matrix VARB

loop j=1..tranches --quiet
    loop i=1..iters --quiet
        y = cum(mnormal(T, 1))+5*j # <--- That is the one!
        DFtaumu[i] = (mols(y[3:], ones(T-2,1)~y[2:T-1], &RES, &VARB)[2]-1)/VARB[2,2]^0.5
    endloop
    sprintf fn "%02d", $j
    mwrite(DFtaumu, "DFTM-@fn.mat")
    printf "Tranche %d of %d: %f s elapsed\n", $j, tranches, $stopwatch
endloop
</hansl>

I am studying the influence of the order of magnitude of the constant on the DF \tau_\mu distribution. The numbers are relatively small for demonstrative purposes. When I run it through gretlcli or gretlcli-mpi, the average running time is 0.2 s per loop of *j* (one tranche).
gretlcli-mpi DFtaumu.inp
However, it seems more correct to use the *$j* instead of just *j* in the loop, so I modified the 14th line by adding a $:
        y = cum(mnormal(T, 1))+5*$j
It seems more correct, yet the performance fell abruptly, the average running time increased by 50%. When the sample size is increased to *nulldata 100000* and *scalar iters=100000*, the average execution time for one tranche increases from 2.01 (without $ sign) to 2.85 seconds (with $ sign).

Why does such a slight change cause such tremendous fall in performance with seemingly no effect on the properties of the output (I compared the distributions of DFtaumu and found no difference). Why? What kind of further optimisation and improvement should be undertaken in order to avoid such pitfalls?

Thank you very much in advance!

--
Yours sincerely,      | С уважением,
Andreï V. Kostyrka. | Андрей Викторович Костырка.
http://kostyrka.ru, http://kostyrka.ru/blog