Hi,
in the context of analyzing the random-number generation in gretl I was
trying to check the overhead of copying the generated values to a
(temporary) variable. I've done this with the following script:
<script>
set echo off
set messages off
total = 1e6
printf "with variable copying.\n"
temptimer = 0
loop total --quiet
set stopwatch # only measure the function itself
scalar temp = muniform(1,1)
temptimer += $stopwatch
end loop
printf " this iteration run time: %f\n", temptimer
print "---------------------"
printf "no variable copying.\n"
temptimer = 0
loop total --quiet
set stopwatch
muniform(1,1)
temptimer += $stopwatch
end loop
printf " this iteration run time: %f\n", temptimer
print "---------------------"
</script>
The funny thing is that the first version of the code that copies the
generated number to the variable 'temp' is about 50% slower than the
version without such copying! See the results below:
gretl-Version 1.9.3cvs
Aktuelle Sitzung: 2011-01-22 18:43
? set echo off
with variable copying.
this iteration run time: 10.310000
---------------------
no variable copying.
this iteration run time: 14.860000
---------------------
Is this expected or is there an unintended thing going on within gretl?
thanks,
sven