performance comparison

 

Hi,

I have a question about using standard library indicators and which one is superior in terms of performance(both RAM and CPU).

for example the MACD indicator handle can be created both by:

CiMACD* MACDhandle;
MACDhandle=new CiMACD()

and by the normal

handle=iMACD(.....);

copybuffer(...);


and then later copying the buffers from the handle. I mean it seem the first method is superior since we don't create an two arrays for the values, what's your idea? which one do you use?

 
Armin Zaribaf:

Hi,

I have a question about using standard library indicators and which one is superior in terms of performance(both RAM and CPU).

for example the MACD indicator handle can be created both by:

and by the normal


and then later copying the buffers from the handle. I mean it seem the first method is superior since we don't create an two arrays for the values, what's your idea? which one do you use?

Internally CiMACD is using handles and the CopyBuffer function, in theory it's performance should be worse because it is an extra layer but
in the real world, you would barely notice the difference between the 2 methods.

My recomendation is to first write the code you need, worry about optimization later and only if you experience problems with performance.
 
Alexandre Borela #:
Internally CiMACD is using handles and the CopyBuffer function, in theory it's performance should be worse because it is an extra layer but
in the real world, you would barely notice the difference between the 2 methods.

My recomendation is to first write the code you need, worry about optimization later and only if you experience problems with performance.

Thanks for the clear answer. I wrote it with CiMACD and for all the other indicators I used this method since it's easier to access the values (I mean skipping the copy buffer from my side), but sometimes I see CPU usage goes to 100 for a fraction of time during testing and I doubted it might be the reason, or the trailing function is causing it as it's runs on every tick.

Reason: