View Single Post
  #5   Spotlight this post!  
Unread 22-02-2009, 23:57
smackee618 smackee618 is offline
Registered User
FRC #1327
 
Join Date: Jan 2009
Location: St. Louis, MO
Posts: 7
smackee618 is an unknown quantity at this point
Re: Create single file for empirical values in labview

Quote:
Originally Posted by Greg McKaskle View Post
Global variables are quite efficient. Write a test to see how long it takes to read a million of something. On the mac laptop I'm using, an empty for loop took 2ms for 1 million iterations. Adding a double precision constant makes it 5. Changing that to a control terminal is also 5. Using a control local makes it 75, and using a global upped it to 77.

All of this was with debugging turned off for the VI. So you have a few nanosecs for this in most cases and when using something that could change at any time and doesn't have optimizations will use more like 70 nanosecs. You can afford that if you do any calculations at all.

By the way, when doing tests like this, avoid using constants for things like loop iterations. If it can, LV will optimize your entire loop to run at compile time to give you unbelievable numbers.

Greg McKaskle
Tell me if I am wrong, but I think that you are telling me that, since I will probably have other calculations running at the same time as I read from these globals, the slight speed decreases will not matter because other, much more processor-intensive tasks will overshadow them.

By the way, could you give me an example of "using constants for loop iterations" and the better alternative? Sorry about my slowness; sleep is a scarcity these days.

One more thing: somewhere along the line there, milliseconds turned into nanoseconds, and I was wondering whether that was intentional.

One more thing (yes I am starting to sound like Uncle from Jackie Chan Adventures): Tanner, thank you for keeping me from doing something extraordinarily stupidly inefficient. I didn't even think about simply using the global data VI.

One more thing: I don't know why, but for some reason I was predisposed toward thinking that global variables were really slow. I think I read about it somewhere. Does anybody know why I thought this?