09-29-2010 09:39 AM
The following snippet demonstrates that a wired red-dot coerce is several times faster than converting the datatype. That's not too surprising, just because I have heard that this is the case, but I would like to know what the red-dot is doing under the hood that makes it so much faster, yet "incorrect" (sort of).
Going further, I wanted to see if the new Coerce To Type would be as fast as a red-dot coerce. Turns out, it is roughly as slow as Convert.
Can someone explain or join in on a discussion about this? Am I wasting time and nodes converting?
Solved! Go to Solution.
09-29-2010 09:44 AM
How valid is your test? Is the compiler smart enough to know that you are converting the same constant many times and reuse the conversion? What about constant folding?
Lynn
09-29-2010 10:02 AM - edited 09-29-2010 10:05 AM
@johnsold wrote:
How valid is your test?
The test is the test. My point is, with THIS vi, Coerce is fast.
@johnsold wrote:
What about constant folding?
Yep, replacing with controls make Coerce slower Replacing the constants with changing numbers does also. Only under the shown scenario is Coerce fastest.
09-29-2010 10:46 AM - edited 09-29-2010 10:47 AM
@broken Arrow wrote:
@johnsold wrote:
How valid is your test?
The test is the test. My point is, with THIS vi, Coerce is fast.
johnsold is correct, its not valid test for "Coerce vs Convert" challenge. Its a test for "Folding vs Folding" efficiency. First you should avoid constand folding (for example, connect index of for loop insted of constant), then your measurement will be more or less correct. Hint: you can turn on visualisation for constant folding in Tools->Options-Block Diagram.
09-29-2010 11:29 AM
It was soooo long ago I don't think I will be able to find the thread or either sure who it was so I'll guess Greg McKaskle, but maybe wrong...
The explicit conversiontakes alittle more over-head than the implied coercion. I have not benchmarked it lately but every time I did the implied coercion was faster.
Ben
09-29-2010 11:44 AM
Are you really running these loops in parallel?
Anyway, I typically don't trust benchmarks with diagram constants and folded loops. They are probably meaningless.
About the difference between implicit and explicit coercion, this old thread might shed some light. 🙂
09-29-2010 12:09 PM - edited 09-29-2010 12:18 PM
Thanks for the link Altenbach! Very informative.
further...
How about if I asked a more specific question regarding my VI:
Given the state of constant folding in these loops, why is coercing so much faster than converting?
09-29-2010 02:09 PM
It is not. Since you have debugging enabled, some extra code is probably generated to prrobe the loops during execution.
If you disable debugging, all times are 0 or 1ms. 😄
09-29-2010 02:13 PM - edited 09-29-2010 02:13 PM
---duplicate---
09-29-2010 03:10 PM - edited 09-29-2010 03:10 PM
@altenbach wrote:
[...]
If you disable debugging, all times are 0 or 1ms. 😄
So coercion is twice as fast.
Thanks Altenbach.