LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Graph axes assignment: performance difference between ATTR_ACTIVE_XAXIS and ATTR_PLOT_XAXIS

Solved!
Go to solution

Hi,

 

I am using a xy graph with both x axes and both y axes. There are two possibilities when adding a new plot:

 

1) PlotXY and SetPlotAttribute ( , , , ATTR_PLOT_XAXIS, );

2) SetCtrlAttribute ( , , ATTR_ACTIVE_XAXIS, ) and PlotXY

 

I tend to prefer the second method because I would assume it to be slightly faster, but what do the experts say?

 

Thanks!  

0 Kudos
Message 1 of 8
(3,811 Views)

Hi Wolfgang,

 

thank you for your interesting question.

 

First of all I want to say, that generally spoken, using the command "SetCtrlAttribute"is the best way to handle with your elements. I would suggest using this command when ever it is possible.

 

Now, to your question regarding the performance difference between "SetCtrlAttribute" and "SetPlotAttribute".

 

I think the performance difference occures, because in the background of the "SetPlotAttribute" command, another function called "ProcessDrawEvents" is executed. This event refreshes your plot again and again in the function whereas in the "SetCtrlAttribute" the refreshing is done once after the function has been finished. This might be a possible reason.

For example you have a progress bar which shows you the progress of installing a driver:
"SetPlotAttribute" would show you the progress bar moving step by step until installing the driver is done.

"SetCtrlAttribute" would just show you an empty bar at the start and a full progress bar when the installing process is done.

 

I think it is like that but I can't tell you 100%, therefore I would need to ask our developers.

If you want, i can forward the question to them, this might need some times. Also, then I would need to know which version of CVI you are using.

 

Please let me now if you want me to forward your question.

 

Have a nice day,

Abduelkerim

Sales
NI Germany
0 Kudos
Message 2 of 8
(3,805 Views)

Hi ADagli,

 

Thanks for addressing the issue. I understand your illustration of the ProcessDrawEvents, but I am simply comparing one drawing action, not many. However the plot may contain many data points and thus I would have expected that reassigning the plot to a certain axis required some additional processing.

 

Yes, I would be glad to learn more about it from the developers.

 

I am using CVI2010.

 

Thanks,

 

Wolfgang

0 Kudos
Message 3 of 8
(3,799 Views)
Solution
Accepted by topic author Wolfgang

Wolfgang,

 

At any given time, there is always an active x axis, and so even when you use method 1, it really is no different and not better than if you had done this:

 

SetCtrlAttribute

PlotXY

SetPlotAttribute

 

whereas, with method 2, it's simply the following subset:

 

SetCtrlAttribute

PlotXY

 

What you should know is that changing the active axis using SetCtrlAttribute is computationally trivial (it will only impact future plots, not any current plots), whereas changing the active axis of an existing plot is not trivial: all the plot data must be remapped, and the plot must be redrawn, among other things.

 

Therefore, if you were to use method 1, it's really as if you were plotting twice: you plot it the first time with PlotXY against whichever is the active axis, and then you plot it a second time, when you call SetPlotAttribute, in case you're actually changing the plot's axis, and not simply setting it to the same axis.

 

There are no trade-offs here. Method 2 is far better.

 

Luis

Message 4 of 8
(3,788 Views)

Thanks, Luis, for confirming my suspicion, I feel much better now Smiley Happy

0 Kudos
Message 5 of 8
(3,784 Views)
Luis,

 

May I add a related question: if I am going to change the axis association, how much time does it take more if I do it myself, i.e. clear the plot, set the active axis, and redraw the plot, instead of changing the plot attribute (which basically involves the same steps)?

 

I am asking because if I am going to change the mapping from linear to logarithmic I will have to replot the data, too, so I am considering a major reorganizaton of my code...

 

Thanks,

Wolfgang

 


LuisG wrote:

What you should know is that changing the active axis using SetCtrlAttribute is computationally trivial (it will only impact future plots, not any current plots), whereas changing the active axis of an existing plot is not trivial: all the plot data must be remapped, and the plot must be redrawn, among other things.


 

0 Kudos
Message 6 of 8
(3,765 Views)

I can't give you exact numbers, but my best guess is that changing the active axis after having already plotted takes about 50% of the time that it would take to re-plot. However, certain settings such as "copy original plot data" or "smooth update" as well as the number of data points in the plot, and the number of other plots that are also in the graph, can have a big impact.

 

I recommend you doing a quick test yourself to see how the times compare. I don't know if you have access to the execution profiler or not, but if you do, but if you do, this would be a good use for it.

 

If you do re-plot, remember to pass VAL_DELAYED_DRAW to the DeleteGraphPlot function.

 

Luis

0 Kudos
Message 7 of 8
(3,761 Views)

Thanks, Luis!

0 Kudos
Message 8 of 8
(3,749 Views)