LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Explicit vs. Implicit Coercion: CLAD test

I was looking at the sample CLAD exam, and have a small question about one of the problems. (See image). I understand why option (B) is undesiriable and bad programming form. What I don't really understand is why it uses more memory. It's the same operation being done, and there is only one buffer allocation done in both cases. In this thread, Ben said he benchmarked coercion, and the explicit cast is actually less efficient than the implicit cast. It's not clear if he was referring to memory usage or speed. My own benchmarking suggests that the explicit cast is about 4% faster.

Message Edited by eaolson on 03-21-2007 04:21 PM

Message Edited by eaolson on 03-21-2007 04:22 PM

Download All
0 Kudos
Message 1 of 4
(4,707 Views)
This question comes up over and over again because of those outdated CLAD examples. Memory usage in LabVIEW has changed *a lot* over the years. That thread you linked to was one that I participated in. I think the general conclusion was that it was a pointless question given the example that was set up, and the "correct" answer was what NI wanted, not necessarily the really correct answer.
Message 2 of 4
(4,676 Views)

"eaolson" <x@no.email> wrote in message news:1174513208275-495425@exchange.ni.com...
I was looking at the sample CLAD exam, and have a small question about one of the problems. (See image). I understand why option (B) is undesiriable and bad programming form. What I don't really understand is why it uses more memory. It's the same operation being done, and there is only one buffer allocation done in both cases. In <a href="http://forums.ni.com/ni/board/message?board.id=170&amp;message.id=187361&amp;query.id=38995#M187361" target="_blank">this thread</a>, Ben said he benchmarked coercion, and the explicit cast is actually less efficient than the implicit cast. It's not clear if he was referring to memory usage or speed. My own benchmarking suggests that the explicit cast is about 4% faster.Message Edited by eaolson on 03-21-2007 04:21 PMMessage Edited by eaolson on 03-21-2007 04:22 PM



Time coercion.vi:
http://forums.ni.com/attachments/ni/170/236938/2/Time coercion.vi



sample_clad_exam4.png:
http://forums.ni.com/attachments/ni/170/236938/3/sample_clad_exam4.png



I had the exact same idea when I read that question. If anything, the automatic coercion takes less memory, because you save a few nodes on the block diagram! The compiled code should be pretty much the same.


Perhaps it's part of the test. You have to know what NI likes to hear to pass.


I think Ben was refering to speed, because one or two extra nodes will only cost 40 bytes or so, and that will be tricky to benchmark. A difference in the compiled code size will be even smaller, perhaps 1 or 2 bytes.


Regards,


Wiebe.
0 Kudos
Message 3 of 4
(4,644 Views)


@smercurio_fc wrote:
I think the general conclusion was that it was a pointless question given the example that was set up, and the "correct" answer was what NI wanted, not necessarily the really correct answer.


There were actually a couple of questions where I was thinking "Well, the obvious answer is X, but Y might be a better choice in some circumstances." I guess I was just expecting more deviousness than there actually was.

0 Kudos
Message 4 of 4
(4,618 Views)