I execute the following code and time one iteration of normal chart display and optimization (the optmizing variables are dummy and won't affect the strategy execution). I know that GVGetNamedXXX is slow, that's why I want to skip it during optimization. However the result is unexpected:
As is:
chart - 38s
optimization - 60s
With "GVGet 1" commented out
chart - 32s
optimization - 44s
With both "GVGet 1" and "GVGet 2" commented out
chart - 27s
optimization - 40s
QUESTION: But why isn't the iteration time of optimization remains constant (at 40s as if GVGetNamedxxx isn't called) since I don't expect the code inside the if loop to be executed at all during optimization.
Code: Select all
Inputs: level(Numeric), s(string);
Var: errorCode(0), printDir(0), content("");
if GetAppInfo(aioptimizing) = 0 then begin
// GVGet 1
printDir = GVGetNamedInt(Text(lwcSymbol(),"GV_PrintDir"), errorCode);
// GVGet 2
if (level <= GVGetNamedDouble(Text(lwcSymbol(),"GV_PrintLevel"), errorCode) or level = 0) then begin
content = Text(FormatDate("yyyy-MM-dd", DateTime), " ",
FormatTime("HH:mm", DateTime), " ",
s);
if printDir = 1 then begin
Print(File(Text("c:\temp\lwc_debug_",CurrentDate+19000000:0:0,"_",lwcSymbol(),".txt")), content);
end;
end;
end; // aioptimizing