LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case order of EVENT structure

LV 8.2.1 - Regarding the order of cases in an EVENT structure:

 

1... Is there any performance (speed) advantage to having the most-commonly used events near the top of the list?  Does it have to search through a list to find which case to execute, or does it happen some other way?  If it searches thru a list, then I want to have the high-frequency events near the top of the list, and the rarer ones nearer the bottom.

 

2... If #1 is "no advantage" then what is the point of the REARRANGE CASES dialog?  Why would I want to rearrange them?  Maybe just to collect them into groups of similar function - is that all?

 

3... When you SORT CASES in the REARRANGE CASES dialog, what order does it put them in?  The help window says "alphabetical" , but that's plainly not true, because my list includes "Stop" and "Clear", and it orders "Stop" before "Clear" after a sort.  It doesn't put the user events together.  A simple test shows that SORT puts them back in the order you added the cases to the structure.  Is there a point to that?

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 1 of 11
(4,491 Views)

1\ Compiled code does not work the same way as interpreting your source code on the fly (read: highlight execution) There is no list of events to choose from, just a load of data and memory locations. As such there is no performance advantage to re-ordering events. The LV compiler knows best and will optimise as it sees fit.

 

2\ I would guess that it is for developer's ease of finding events as you suggested

 

3\ Perhaps the sorting algorithm sorts by the index of the events; the index being the order in which they were added. I don't know why this may have been chosen :-S

_____________________________
- Cheers, Ed
0 Kudos
Message 2 of 11
(4,478 Views)

1... OK, that makes sense.  My rule for years has been to give LabVIEW all the flexibility you can, and it does its best. 

 

2... I suppose if I come back a month later and add a new DO IT button, I want to group that event next to the previous nine DO IT button events.

 

3... The HELP for that topic is plainly incorrect, it says "alphabetical order" is the result of sorting. Even though these are "user-defined events in quotes", I would expect them to be sorted into alphabetical order, based on the help description.

 

If I have an ENUM with values "Wednesday", "Thursday" and "Friday", and add a CASE structure with three cases in it, a SORT always puts them in WTF order (no pun intended).

If I rearrange the ENUM into WFT, then sort the CASEs, they change to match the ENUM.

Alphabetical order has nothing to do with it.

 

Anyway, thanks for your thoughts. 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 3 of 11
(4,463 Views)

I believe the event structure does actually do a linear search over the list of events (OK, found a reference), but that's an implementation detail and I doubt it would have a serious impact on performance.

 

Regarding the sorting, is it possible you have some invisible chars (like a leading space) or that one of the words starts with an uppercase letter and the other with a lowercase one?


___________________
Try to take over the world!
0 Kudos
Message 4 of 11
(4,445 Views)

is it possible you have some invisible chars (like a leading space) or that one of the words starts with an uppercase letter and the other with a lowercase one?

Nope.  Try it yourself with the Wed, Thur, Friday trick.

 

The EVENT structure cares about what order you created the cases in.

The CASE structure cares about the order of whatever drives the selector.

 

Alphabetic order seems to have nothing to do with it. 

 
From your reference thread:
However, this does tell you that if you want to squeeze every ounce of performance out of your event-handling code, make sure the most frequently run event-handling diagram is the first one in the list.
This from a LabVIEW R&D engineer.
 
Hmmm. 
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 5 of 11
(4,441 Views)

You're right that sorting cases based on an enum will sort according to the enum values (which makes some sense because an enum is a numeric value, not a string).   You're also right that the documentation vs. the behavoir is definitely not intuitive, if not entirely misleading.  FYI, this has been submitted to R&D as either a needed change in documenation or behavoir.  As always, thanks for the feedback!

 

Concerning the order of cases:  yes, your quote is true that order will let you "sqeeze out every ounce" but this is such a small sqeeze it seems hardly worth considering. 

Brian A.
National Instruments
Applications Engineer
0 Kudos
Message 6 of 11
(4,392 Views)

As of today, the Help still says that "Rearrange Cases" will sort cases alphabetically when it clearly does not. So R & D obviously did not consider this a major issue, when it cleary is when you have dozens of cases to sort through...

0 Kudos
Message 7 of 11
(4,026 Views)

You're correct.  The Sort button doesn't sort events alphabetically like the help file says.  It seems to sort them by order of creation.

 

There should have been a CAR# created for this.

0 Kudos
Message 8 of 11
(4,008 Views)

Hi,

 

Yes, it is correct that the documentation is still wrong and the sort will not sort the cases in alphabetical order.  There is currently a Corrective Action Request (CAR) in work for this problem (#109501).  Look for this number in the release notes of future LabVIEW releases.

 

Have a great day,

 

Chris

Applications Engineer
National Instruments
Message 9 of 11
(3,976 Views)

So what's the corrective action going to be? Correct the help file by stating that it DOES NOT sort events alphabetically, or correct the action and let it sort events ALPHABETICALLY. I'd rather see the latter happening!

0 Kudos
Message 10 of 11
(3,944 Views)