One of the things i have at the moment is sorting algorithms more
or less coming out of my ears and I have learnt something that is
very simple to make them generally go faster.
PowerBASIC has default optimisation if you don't turn it off with
#REGISTER NONE which automatically allocates any available registers
to variables. What you can do is set the order of priority with
the LOCAL variables at the beginning of the SUB/FUNCTION so that
the most used variables are the ones that are allocated to the
available registers and almost exclusively you will get a measurable
sped gain from doing so.
In most of the sorting algorithms there are a pair of variables
that are used as the indexes for the array locations. These variables
are the most used ones and are used in recursive loops so any gain you
can get with the most used variables will make your code go faster without
having to touch the code at all.
If the variable are written similar to the following,
LOCAL counter as LONG
LOCAL Temp as LONG
LOCAL Upper as LONG
LOCAL Lower as LONG
LOCAL Index1 as LONG
LOCAL Index2 as LONG
If Index1 and Index2 are very intensively used in the algorithm,
just by moving them to the top will get a reasonable speed gain
without having to modify the code at all.
Regards,
[email protected]
------------------
or less coming out of my ears and I have learnt something that is
very simple to make them generally go faster.
PowerBASIC has default optimisation if you don't turn it off with
#REGISTER NONE which automatically allocates any available registers
to variables. What you can do is set the order of priority with
the LOCAL variables at the beginning of the SUB/FUNCTION so that
the most used variables are the ones that are allocated to the
available registers and almost exclusively you will get a measurable
sped gain from doing so.
In most of the sorting algorithms there are a pair of variables
that are used as the indexes for the array locations. These variables
are the most used ones and are used in recursive loops so any gain you
can get with the most used variables will make your code go faster without
having to touch the code at all.
If the variable are written similar to the following,
LOCAL counter as LONG
LOCAL Temp as LONG
LOCAL Upper as LONG
LOCAL Lower as LONG
LOCAL Index1 as LONG
LOCAL Index2 as LONG
If Index1 and Index2 are very intensively used in the algorithm,
just by moving them to the top will get a reasonable speed gain
without having to modify the code at all.
Regards,
[email protected]
------------------
Comment