PureBytes Links
Trading Reference Links
|
>I have a system that is based on a long program (800 lines of code)
>and I want to study some optimization of its few inputs. If
>I convert its primary variable to a function and then use that
>function in the strategy rather than just have it computed
>inside the strategy will that make the code faster when I run
>optimizations?
No, that will actually make it slightly slower because of the additional
overhead of a function call. However, this overhead will not be
noticeable. It might be a difference of a millisecond per run.
The best ways to enhance speed are:
1. remove unecessary calculations from inside loops.
2. use constants instead of calculations when possible;
for example, use 1.4142136 instead of SquareRoot(2).
3. eliminate loops where possible; e.g.
a. use exponential functions; e.g. XAverage rather than Average
(average uses loops).
b. write optimized replacement functions that take advantage
of a data stream; for example, sum() can be optimized to
require a loop only on the first bar, and no loops afterward.
-Alex
|