You're welcome Aurel,
And no, this isn't DynC. This is FBSL's interpretative BASIC -
toy.fbs "compiled" into a usual FBSL executable. I haven't yet tried Ed's C version in FBSL DynC but I'm sure it'll run a few dozen times faster than this script. I think the FreeBASIC version in fact runs also much much faster than it seems.
Anyway, you can time it yourself adding the following lines
.............
dim gtc = GetTickCount()interpret()
print "completed in ", (GetTickCount() - gtc) / 1000, " seconds".............
to
sub main() to measure the exact time it takes to find, say, 10000 primes. You can also add similar timing to the FreeBASIC script in its
sub main() using its
Timer and
Print keywords and recompile the script to see the real benchmark figures. Make sure your FbEdit
Options->Build Options->Command contains the
fbc -lang qb -s console parameters when recompiling it.
In either case, the bottleneck will be the
Print statement which is rather slow and unpredictable speed-wise in every language. The arithmetics loop proper will run much faster without it and you can only let primes.toy print the last result to the console so that you can check if the code runs properly in the both languages you're trying to compare.
Finally, the "dirty hack" isn't so good for line parsing as it may seem at a first glance - it is very slow while doing it. Oxygen has a built-in
getfile() function which is similar to FBSL's
FileGet(BINARY). And you can use an Oxygen equivalent to my
function get_line() (the bottommost function in the toy.fbs script) to parse the code buffer into successive code lines. This will be much faster than calling the richedit control to yield its lines of text. Richedit has to do quite a lot of conversion internally before it can give you what you want.