Jump to content

Variant To Data. Which is faster?


Recommended Posts

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.

Link to comment

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.

Link to comment

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?

Link to comment

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.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.