04-15-2020 10:12 AM
@AristosQueue (NI) escreveu:
Second, I've seen benchmarks written by various programmers attempting to benchmark the cost of dynamic dispatching specifically, and they always are testing something else. Easy example: if you're seeing a 10x jump in cost, you're injecting a data copy somewhere in your test. The dispatch cost doesn't change like that.
Ok, let's just forget about that number, it was a really quick test just changing the connector pane.
Timing something like this purely in G is extremely difficult because it is so small and because just dispatching is not isolateable as a subVI. The VI is always doing other things as part of the call (such as returning from the call), and it is the entire call that is being timed. Timing just dispatching overhead really requires C++ level checking.
Just like I said, as it is so difficult to measure and it is so small, it is not even worthy discussing performance, we just follow the best practices.
As of my choice, I am choosing OO for some extra benefits that it brings, and it is going to suffice my needs. Thank you all for the feedbacks and let's keep coding.
Regards,
Felipe
04-16-2020 05:36 AM
@AristosQueue (NI) wrote:
With extremely high confidence, I state, "Your benchmarks are wrong."
I
Ah, but yours are too, no. Anyway, Variants (for simple data at least) are definitely not millisecond-level operations. Microsecond-ish. Can't say for DD calls.
Anyway, re the OP: given that your using the AF, where the "Write Message" and "Do" methods are in the same library, have you considered doing the type-conversion work on the sender's side in the Write? So have a "Write Value (Digital)" method, that takes an integer, and a "Write Value (Boolean)" method that takes a Boolean and converts to 0,1 then calls "Write Value (Digital)". Then your message is always an integer, and you need neither Variants nor a set of Type classes, and there is never any type casting. Sending code can choose which method to use.
04-16-2020 06:10 AM
@drjdpowell escreveu:
Anyway, re the OP: given that your using the AF, where the "Write Message" and "Do" methods are in the same library, have you considered doing the type-conversion work on the sender's side in the Write? So have a "Write Value (Digital)" method, that takes an integer, and a "Write Value (Boolean)" method that takes a Boolean and converts to 0,1 then calls "Write Value (Digital)". Then your message is always an integer, and you need neither Variants nor a set of Type classes, and there is never any type casting. Sending code can choose which method to use.
Nice point. Although this is only one of my simple examples. In fact sometimes there could be more structured data types. But thinking in your example, we can even consider using a malleable VI in the Accessor Write side. Can't we?
04-16-2020 06:23 AM
@felipe.foz wrote:
But thinking in your example, we can even consider using a malleable VI in the Accessor Write side. Can't we?
You can use Malleables on the Write side, yes.