Hi all -
I've been working on a tool to analyze the compiled code complexity for VIs in a project/directory. (this is a new feature in LabVIEW 2012) I've attached the tool below. There are two steps to use it:
The front panel of "analyze complexities.vi" looks something like this:
On the bottom is a histogram of code complexities. Above that are some statistics (the most interesting being how many VIs were only compiled with partial optimizations), and to the right are all the VIs sorted in descending order of code complexity, so you can easily see the biggest ones. It also finds VIs that could be inlined and have a low complexity, and shows them under "VIs to consider inlining".
I think this will be useful for larger projects for informational purposes, to find VIs that are "too big" and not being compiled with full optimizations, and finding VIs that are good candidates for inlining.
I'd be happy to answer any questions about the tool!
No traffic on posts like this generally means we don't get it.
I'll play along.
If I have been writting code for years that works fine and runs fast, why is this of any interest to me?
What is my motivation?
Fair enough - I'll do my best to motivate it 🙂
If you have VI's with code complexity greater than 5, then that means
- they're not being compiled with full compiler optimizations, so they'll run slower than they could
- they're big and probably good candidates for refactoring
If you have VI's with very small code complexity, they're probably good candidates for inlining, which will make them run faster.
This project will help you find VI's in both categories. (I'm into numbers, so I love the graph of the frequency of code complexities, but it's not that useful)
while i appreciate your effort, i would expect such features to be part of the VI Analyzer. In fact, inlinability (does this word exist at all?) is already tested with VI Analyzer:
So do you think it will be possible to integrate your effort for the compiler optimization analysis into VI Analyzer for e.g. 2012 SP1?
Hi Norbert -
I chatted with Darren about this, and we decided that the tests that already exist in VI Analyzer make more sense, especially the "Complexity Metrics" ones since they call out specific things you can do to simplify your VI. I will admit I didn't know there was an "Inlinable VIs" test...somehow I missed that.
but VI Analyzer does not (at least, i am not aware of it) tell you what compiler optimization level was used for the individual VI. I think this could be valuable information, too. And i understand that your tool does test this 😉
Very late to the party here, we're going to be discussing this at our next user group.
I'm interested in what LabVIEW considers complex (rather than the VI Analyzer metrics). Is there a white paper on how this number is calculated?
Many thanks for the tool.
Well here's several links a google search turned up.
I don't think LabVIEW determines what is complex, only how complex is some code. Only a human can determine what is too complex, or possibly a human setting some limit for software. Does it have code smell? Its probably too complex. But since it is a subjective test, two developers may disagree on what is too complex, which is why counting the number of nodes, or number of branches, can put a value on the complexity of software.
I'm not so much interested in code complexity from a VI analyzer, or even a human point of view. I'm interested in the algorithm used to calculate it from the compilers point of view. Or maybe they're the same.
So it's specifically how this number is calculated.
I'll do some tests with VI Analyzer too.