Dear all,
I just stumbled about this Julia post
https://www.juliabloggers.com/when-julia-is-faster-than-c/
and translated the code to hansl. Running the original Julia code on my
machine with 10^7 iterations takes about 0.19 seconds. Running the hansl
code below takes about 19 seconds which is 100 times slower compared to
Julia. I am pretty sure there is a much more efficient way to set this
up this up using gretl+hansl (Jack? :-D ) -- but this is not my point.
Let's just assume the average user would set up things as simple as
possible.
I am just curious to know at which point Julia makes it seemingly better
compared to C and hansl? Any ideas? Btw, I can't see that Julia makes
any use of parallelization -- according to CPU information only a single
core is fully used. The same holds for gretl.
<hansl>
function void euler(int n, scalar *mn) # pointer form
scalar m = 0
loop i = 1..n -q
scalar the_sum = 0
loop while the_sum<=1 -q
m++
the_sum += randgen1(u,0,1)
endloop
endloop
mn = m/n
end function
set verbose off
clear
set stopwatch
scalar mn = 0
euler(10^7,&mn) # originally 10^8
printf "This took = %.6f sec.\n", $stopwatch
mn
<hansl>
Best,
Artur