pete_dunham Posted May 6, 2009 Report Share Posted May 6, 2009 Working on some code...and am not sure which one is faster. And more importantly the reasons why #1) #2) Quote Link to comment
ned Posted May 6, 2009 Report Share Posted May 6, 2009 I'm not sure about faster, but in general in this sort of situation you're better off doing the conversion inside the loop so that you only allocate a single variant rather than an array of them. Quote Link to comment
asbo Posted May 6, 2009 Report Share Posted May 6, 2009 This is just kind of a shot in the dark, but I would say that #1 is better for speed and #2 is better for memory. #1 only calls VTD once but does have to allocate the n-array buffer ned mentioned. #2 calls VTD many times but only allocates one array (and it can pre-allocate it, at that). Unless you're running on a P133, the speed difference is likely negligent. You can test this by passing in a very large cluster (1000+ elements) and see what kind of times the profiler gives you. Without knowing more about the cluster in question, I'm not sure which method I would choose. If you don't know, you can see where buffer allocations occur by going to Tools > Profile > Show Buffer Allocations. Quote Link to comment
Mellroth Posted May 6, 2009 Report Share Posted May 6, 2009 QUOTE (pete_dunham @ May 5 2009, 02:36 AM) Working on some code...and am not sure which one is faster. And more importantly the reasons why Hi, I don't know what you are trying to do, but I would typecast the control reference to a strict boolean directly. My guess is that this is better both in terms of performance, and memory. And, if you know that all your elements are booleans, you could typecast the array of references directly into an array of strict booleans, before entering the loop. http://lavag.org/old_files/monthly_05_2009/post-5958-1241530862.png' target="_blank"> /J Quote Link to comment
pete_dunham Posted May 6, 2009 Author Report Share Posted May 6, 2009 Thanks for the replies. I should have worded my question as a better way to program. I was looking for better memory/performance as opposed to how fast the code excutes. The code you provided looks good and made sense. I got stuck when I was changing my code to a (strict) reference throught my Class Specifier constant. I kept looking for different ways to get this Constant strictly defined... I ended up having to change my Class Specifier Constant to a control, and then click on the control and choose "Include Data Type" and then change this control back to a constant. This seemed like a long way around...is there a more straightfoward way? Quote Link to comment
ned Posted May 6, 2009 Report Share Posted May 6, 2009 QUOTE (pete_dunham @ May 5 2009, 12:32 PM) I got stuck when I was changing my code to a (strict) reference throught my Class Specifier constant. I kept looking for different ways to get this Constant strictly defined...I ended up having to change my Class Specifier Constant to a control, and then click on the control and choose "Include Data Type" and then change this control back to a constant. This seemed like a long way around...is there a more straightfoward way? Generally I right-click on the block-diagram terminal of a control or indicator, choose create->reference, then right-click the reference and choose create->constant in order to create a strict type specifier constant. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.