LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Understanding code complexity

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.

Message 1 of 25
(3,114 Views)

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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 25
(3,087 Views)

I'm not sure if this is what you are looking for?  Analyzing Code Complexity with VI Analyzer Toolkit?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 25
(3,076 Views)

@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?

0 Kudos
Message 4 of 25
(3,050 Views)

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.

0 Kudos
Message 5 of 25
(3,031 Views)

@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. Smiley Very Happy

Message 6 of 25
(3,018 Views)

@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. Smiley Very Happy


Yeah, my boss keeps moaning about our lack of productivity nowadays.

 

My new VI was programmed in 2012 days........ Smiley LOL

Message 7 of 25
(2,979 Views)

@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. Smiley Very Happy


Yeah, my boss keeps moaning about our lack of productivity nowadays.

 

My new VI was programmed in 2012 days........ Smiley LOL


Things became very inefficient between 8.6 and 2009.

0 Kudos
Message 8 of 25
(2,974 Views)

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. 🙂

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 25
(2,966 Views)

But on a more serious note.

 

 

Spoiler

C#

 

Spoiler
No, seriously serious,  I'll try copying everything into an empty VI to see if things improve.  I'm skeptical to be honest, but we'll see.

 

 

 

0 Kudos
Message 10 of 25
(2,959 Views)