09-24-2009 03:38 PM
09-24-2009 04:24 PM
The 'for' loop language construct is as efficient as you're going to get, for iterating through data. I would suggest that if you can maintain your data in sorted order (i.e. order is not inherently important to the data), then you can do a binary search on your data, instead of a linear search. What kind of data do you have? Could your comparision operation be expensive? Can you optimize away some data copies or pointer dereferences?
Have you tried the release configuration? The debug configuration can be slower, and if you're running in the debugger and have watch expressions, you'll run WAY slower.
Mert A.
National Instruments
09-24-2009 04:28 PM
09-24-2009 04:39 PM
If the debug build is slower, it would probably be due to runtime checks that get built into the code. You cannot disable these for a particular span of code, but you could disable runtime checking for your whole program by setting "Debuging level" to "No run-time checking" in the Options>>Build Options dialog.
However, I really don't think that's the way to solve your problem. Could you post the code for the loop that's too slow? In what sense is the loop too slow? Maybe with some specific details about your data, what you're doing, and what kind of response you need, we can figure out a way to optimize.
Mert A.
National Instruments
09-24-2009 04:46 PM
09-24-2009 04:55 PM
Setting the debugging level to "no run-time checking" does not completely disable the debugger. You can still set breakpoints, view variable values, etc. -- you just don't have automatic safety checks (pointer arithmetic, array bounds, etc) compiled in. These checks are either compiled in, or they're not, and there is no function you can call to bypass them.
I do not know of any such analysis function.
Mert A.
National Instruments.
09-24-2009 05:00 PM
09-24-2009 05:07 PM
Sorry, no. There is no such pragma to toggle the inclusion of runtime checks.
Have you actually noticed a significant difference between the performance of the release and debug configurations? That would be the first thing to try, because if the release configuration still seems slow, then you know that you have to do some actual code optimization.
Mert A.
National Instruments
09-24-2009 05:16 PM
09-24-2009 05:32 PM
If you want part of your program in release mode while the rest is in debug mode, then I think the DLL route may be the only way to go. In the samples directory, I'd check out dll\basic. It should be what you need. Take a look at the readmes for step-by-step instructions.
Mert A.
National Instruments