12-03-2014 08:23 AM
Hello,
I want to develop an universal Network stream subVI that can be used to transfer any type of data, depending on what data type you connect.
I found that I should use Variant Type and I have done it.
But there is a problem that my application performance is slower now. I even used GetTimeStamp and it seems that time between loop has changed from 356us for U8 data to 2212us for Variant type, where I connected U8 too.
Communication is working, but there is no difference in send time if I send U64 of U8.
Transmission is slower in comparicon to program with fixed U8 connected.
Maybe I am doing wronk with that type. How can I manage with that?
Or there is no option to do that because variant type reserves the biggest size.
Pieces of code:
ON RT:
ON PC:
Best regards,
Chris
12-03-2014 08:31 AM
A variant does not have a fixed size, therefore there is more memory activity involved. The U8 and U64 are fixed sizes, so some shortcuts can be made. You really should used fixed sized items if you really care about performance. Strings and arrays should have this same issue.
12-03-2014 09:12 AM
Yup, Varient is not the way to go here! this is one of those times you want a polymorphic vi and force the developer to determine data type before compile.
Yes the developers will howl! you can beat them into submission- making the developers happy in this case will disapoint the USERS- beating users into submission is considered "Bad Form." Eventually the users go somewhere else and the heretofore happy developers need to seek other employment.
12-03-2014 10:17 AM
I do understand that.
I am still searching for optimal solution to make it universal for any connected data type.
I have tried to make an Enum Case selector on Network Stream Endpoint Create but it failed because the reference passed later depends on datatype.
Now I am thinking to make a Polimorphic VI, but then I am supposed to build a VI for any data Type that I might use and then apply it in one. That is still a big waste of memory for the code that is the same for the every type.
Maybe someone knows different solution?
12-03-2014 10:43 AM
@BiedaK wrote:
Now I am thinking to make a Polimorphic VI, but then I am supposed to build a VI for any data Type that I might use and then apply it in one. That is still a big waste of memory for the code that is the same for the every type.
Well, that is the drawback to polymorphic vis. it breaks the "Code it once" rule untill you consider type propigation. Polys are harder to maintain than your average vi. In this case i'd still go with the poly. The performance trade-off is worth your suffering- and usually when you create a poly you mock-up one instance first- thoughly test and document it, Make it pretty! then do some "Saving-As" magic and thank the IE for the ability to change Representation on multiple numerics in one right-click.
12-03-2014 10:49 AM
Jeff·Þ·Bohrer wrote: then do some "Saving-As" magic and thank the IE for the ability to change Representation on multiple numerics in one right-click.
That's too much work. Make a scripting VI to do it for you! I made this one to handle all of the numerics.