Oxygen Basic

Programming => Problems & Solutions => Topic started by: Aurel on February 03, 2014, 01:40:25 PM

Title: Speed of loop
Post by: Aurel on February 03, 2014, 01:40:25 PM
Hi Charles
I want to increase speed of loop which read ordinary integer array elements
I tested for,while and do loop and i think that do loop is the fastest.
Also i try with assembler like this:

Code: [Select]
mov ecx,0
again:
....
.....
....
dec ecx
jnz again

But i have found that this way is not faster than with ordinary do
Only thing what i see is that this method use little bit less memory..
Is there a faster way or maybe i do something wrong ..?
Title: Re: Speed of loop
Post by: Charles Pegge on February 03, 2014, 03:07:57 PM
Oxygen compiles to efficient asm/machine code so there is not much to be gained, except in very specific situations, where spare registers can be used instead of variables. But local variables are held on the stack, which is usually contained within the CPU cache (very fast memory).

To get the best performance, ensure that there are no unnecessary repetitions, and turn small, frequently used functions into macros.
Title: Re: Speed of loop
Post by: Aurel on February 03, 2014, 09:45:14 PM
Ok..i will try with macros.. ;)