06-13-2013 08:02 AM
I recently refactored a legacy VI which was programmed in 7.1 days. It involved the usage of about 20 occurrences to trigger many parallel loops, each of which contained a simple operation.
The code had a complexity of 7.3 (2012 property).
I refactored the code to include a nice producer consumer architecture, got rid of FP elements for temporary data storage, introduced a state machine for handling UI updates and generally optimised what I could according to my understanding of good coding.
After all that I have a code complexity of 6.8. I was expecting a MUCH larger drop than that.
What exactly determines code complexity? What has a large impact, what has a small impact? If I compare the VI I modified with a version of the OLD VI which a colleague changed (a lot lot less than I changed) his version gives a code complexity of 4.3 (with 20 parallel loops coordinated with occurrences, each with their FP component and using Locals everywhere).
Both the memory footprint of my version is about 50% higher than before and the code size is double that from before. How can this be?
The one major change I made was using user events to communicate between my consumer and producer. My API has a total of 40 user events, not exactly a lot really.
06-13-2013 09:20 AM
Could it be attributed to the notion of "How hard is this for another to understand"?
If so, events are harder to understand than loops and local variables.
I remade a testprogram due to too big version difference, and went from 200ish vi's and 5Mb code to 40-50 and 1,5Mb code. 🙂
/Y
06-13-2013 09:38 AM
I'm not sure if this is what you are looking for? Analyzing Code Complexity with VI Analyzer Toolkit?
06-13-2013 12:03 PM - edited 06-13-2013 12:03 PM
@billko wrote:
I'm not sure if this is what you are looking for? Analyzing Code Complexity with VI Analyzer Toolkit?
No that's not what I'm looking for.
For me the program as it is now is FAR more readable and understandeable for a human, but for a computer? I dunno.
I tried blanking out parts of the code and apparently my event structure (operating purely on user events) which basically simply receives data per user events and places them in a cluster is the offender. UI operations are performed AFTER this event structure _(a loop which doesn't add significantly to the complexity).
Why on earth does an Event loop with a lot of "Insert this data into a cluster" give sich high complexity?
06-13-2013 12:39 PM
Intaris wrote:
Both the memory footprint of my version is about 50% higher than before and the code size is double that from before. How can this be?
It's been a while, but I think I've seen (and seen reports of) cases where updating a VI from an old version caused a large increase in the VI file size. Copying the contents of the VI to a new, blank block diagram and saving that resulted in a much smaller file.
06-13-2013 01:33 PM
@Intaris wrote:
I recently refactored a legacy VI which was programmed in 7.1 days.
That's a very exact measurement of the time it took.
06-14-2013 01:14 AM
06-14-2013 01:59 AM
@Intaris wrote:
@for(imstuck) wrote:
@Intaris wrote:
I recently refactored a legacy VI which was programmed in 7.1 days.
That's a very exact measurement of the time it took.
Yeah, my boss keeps moaning about our lack of productivity nowadays.
My new VI was programmed in 2012 days........
Things became very inefficient between 8.6 and 2009.
06-14-2013 02:25 AM
Things became very inefficient between 8.6 and 2009.
It's been missed in the patch notes, but they've changed the base unit to minutes for a better resolution. Now stuff is done i 2012 mins, or ~4.2 days. 🙂
06-14-2013 02:39 AM