LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read DVR - Which code is more efficient

Solved!
Go to solution

Hi, can someone explain to me which of the two images contains the more efficient code ?

 

charlie87_0-1760164489454.png

 

charlie87_1-1760164516963.png

 

 

0 Kudos
Message 1 of 7
(365 Views)
Solution
Accepted by topic author charlie87

My gut feel is that these are basically equivalent. It is possible the compiler creates the same code. Even then, the difference between these two will be so minute it probably is not worth the effort.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 7
(335 Views)

Hi Charlie,

 

Regarding performances, I would be more concerned about the fact that your object contains another object of the same class inside the DVR, on which you have to use "to more specific".

 

Why not having a DVR to a variant directly (or maybe a DVR to a cluster containing the variant)?

 

Regards,

Raphaël.

0 Kudos
Message 3 of 7
(316 Views)

@raphschru wrote:

Hi Charlie,

 

Regarding performances, I would be more concerned about the fact that your object contains another object of the same class inside the DVR, on which you have to use "to more specific".

 

Why not having a DVR to a variant directly (or maybe a DVR to a cluster containing the variant)?


It has indeed a possible code smell. Looks like a linked list implementation. It might be eligible, but it feels itchy.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 4 of 7
(252 Views)

@raphschru wrote:

Hi Charlie,

 

Regarding performances, I would be more concerned about the fact that your object contains another object of the same class inside the DVR, on which you have to use "to more specific".

 

Why not having a DVR to a variant directly (or maybe a DVR to a cluster containing the variant)?

 

Regards,

Raphaël.


I think this is just an "alternate" version of the way GOOP does its "by-reference" implementation.  GOOP flattens a DVR pointer to a U32 and stores that since it can't have a DVR of itself inside itself.  A class containing a DVR to a "LabVIEW object" is also non-recursive but can still store an instance of itself inside of itself during runtime.  The fact that it's unbundling a "Variant" is likely just part of the code example.

Message 5 of 7
(214 Views)

@Kyle97330  a écrit :

@raphschru wrote:

Hi Charlie,

 

Regarding performances, I would be more concerned about the fact that your object contains another object of the same class inside the DVR, on which you have to use "to more specific".

 

Why not having a DVR to a variant directly (or maybe a DVR to a cluster containing the variant)?

 

Regards,

Raphaël.


I think this is just an "alternate" version of the way GOOP does its "by-reference" implementation.  GOOP flattens a DVR pointer to a U32 and stores that since it can't have a DVR of itself inside itself.  A class containing a DVR to a "LabVIEW object" is also non-recursive but can still store an instance of itself inside of itself during runtime.  The fact that it's unbundling a "Variant" is likely just part of the code example.


Now that I think about it, the class may have some methods that operate on the "by-ref" version of the class (where "variant" data is void), and other methods that operate on the "by-value" version of the class (where "DVR" is null). I don't think this is for class composition though.

0 Kudos
Message 6 of 7
(198 Views)

 understood the code very well. Do not bother with the variant unbundle. I am using this construction very often to get the attributes from the class instance stored in the DVR. It is called many times, so I was wondering if the code is optimized as much as possible.

0 Kudos
Message 7 of 7
(183 Views)