Color Shading and Inserting Text to Profile VIs Visually

What bugs me about the VI Profiling Tool is that it is not intuitive. The information it provides is really useful; however, it's so hidden and difficult to interpret that few people actually know where it is to use it. Let's say you are simply acquiring data using DAQmx and writing that data to a file, as below:

You might want to find out how to make this more efficient, but the only way you know is to insert Tick Count VIs and wrap your wires through sequence structures to do it. It's annoying, and there are other ideas from JackDunaway (here) and JohnMc19 (here) which aim to simplify the use of those VIs.

But why re-code your application when the VI Profiler can do it for you? In addition, the VI profiler has more timing information (longest, shortest, average, total, etc) as well of number of runs and memory allocation data.

Good news: VI Profiler makes getting the data easy.

Bad news: VI Profiler makes using the data difficult.

Why Using the Profiler is Difficult

First, you need to know it exists among a number of bland and condensed gray menus (Tools>>Profile>>Performance and Memory).

Next, you have to coordinate starting the profiler with starting your VI (start the Profiler, then start your VI, then stop your VI, then stop the Profiler).

Finally, you have to dig through a TON of VIs to find the ones that are relevant (I assume this is because, for polymorphic VIs, all of the instances are loaded into memory, even the dozens that aren't currently being used.)

When you find the VI you wish to examine, it will look something like this:

Have fun sorting through that! When I finally find a VI that's hogging memory or speed, I'd expect to click on it to navigate to that VI. NOPE! All the VI Profiler does is make the line bold. Not particularly easy to use...

I can't say if it's possible to get rid of VIs that aren't being used, or to make the menu option more visible to the user, but I do have an idea or two for how to make this information easier to understand in LabVIEW.

So here's what I suggest:

Adding a couple of check-boxes to the top of the VI Profiler will view in relation to your LabVIEW VI. Notice the extra check boxes in the top of this image.

One checkbox allows you to color the column you wish to highlight in your LabVIEW code. The other checkbox inserts a text comment containing the highlighted data straight into you LabVIEW code (right next to the sub VIs):

From the above picture, you can clearly see the Write to Spreadsheet File VI is the slowest to execute. Next in line are the Start DAQmx Task VI and then the Stop DAQmx Task VI. So if a developer wanted to find out how to make his loop run faster (and therefore increase the rate data is read from his PC RAM), he would know the VIs that are more red are the ones he needs to focus on first.

Also, if a user wants to highlight the memory usage, he could select a memory column from the VI Profiler.

Then the LabVIEW block diagram would look like this:

In this case, if a developer wants to find out how he can optimize his code for memory usage, he knows where to start.

Side-note: I think selecting multiple colors at a time (one for each column of data you wish to highlight) would be cool, but that would start to get messy on the block diagram.

Other data, like the number of runs, could highlight which sections of code are running more often than others.

If we integrate the VI profiler more effectively into LabVIEW, there are a lot of benefits:

I think that selecting multiple columns could work, and here's how: Instead of having many different colors (as you said, that would get ugly), it would only be one color. Selecting multiple columns would put each piece of information in the label near the subVI, and the color intensity would be an overall "badness" of the subVI.

The badness could be an aggregate, perhaps weighted, perhaps not, of each of the selected columns. Also, this "Badness" would be displayed in the label. 0 is not bad, +inf is superbad.

Example:

If the user selected Avg Mem and Avg Run Time:

You'll notice that some VI's have the same Badness number: the weighting determined that they are essentially equal - one is faster but takes more mem, the others slower, but are more memory-efficient. (Ok, really, they are the same because I got lazy...)

If you REALLY wanted to make it customizable, you could let the user determine the weight of each profiler column. Some people don't care how much memory it takes, as long as it's fast. Others are the opposite.

Thanks for bringing that to my attention--I didn't realize that was there! From an intuitive standpoint, there's no reason for me to believe that clicking on the line and clicking on the VI name, specifically, would have different effects. Either way, I still hate the listbox format. I think the color shading will be a world of difference for using this tool.

While we're on the topic of sub-VIs (I didn't want to bring this up in the article, but I guess I'll mention it here.) What I'd REALLY like to see is double-clicking on a VI on the block diagram opens the subVI, which has its own block diagram shaded with relative intensities, as well.

This makes the situation a little sticky, because I'm not sure if shading in subVIs should be absolute or relative. I can see users wanting either, for a couple of reasons:

1) Relative Shading within Sub-VIs - what I mean by this is that all the sub-VIs on a single block diagram are only shaded in reference to other sub-VIs on that same block diagram. This is most intuitively understood by looking at the images in this article.

Good news - you can focus on just one block diagram at a time, so it's straightforward.

Bad news - you could be so focused on one dark red sub-VI on one block diagram, you're missing a bigger resource hog under a different sub-VI.

2) Absolute Shading within Sub-VIs - in this case, the subVIs on a single block diagram are shaded not only with respect to each other, but also with respect to other VIs loaded in memory (all VIs loaded under a single top-level VI, for instance).

Good news - You can compare different sub-VIs to each other and find out which is the bigger resource hog.

Bad news - It may be confusing to a user who only wants to concern himself with one VI at a time.

I know this addendum adds a little more complexity, but I'm hoping it doesn't take away from the original idea. Whether to use absolute or relative shading could probably just be an extra option within the preferences.

Neat idea. I was thinking that the shading and the metrics display could get messy quick. How about a badge on each VI with a simple colored bar showing the relative value of each selected column. When you are looking at this stuff, it's less important what the actual numbers are than what they are in relation to others. Also, this way you could select multiple metrics and see them all at the same time.

I still tend to think the metrics are important, but the color bar would make things easier to compare when actually analyzing the VI. Because shading a VI is more visually engaging, it is better for understanding what's happening at-a-glance. However, once you start to think about which subVI is executing more slowly relative to others, the color bar definitely takes the cake.

C. Minnella -- I liked your suggestion so much, I thought I'd include an image of what that might look like:

After playing with this, I realized that there will probably be some additional questions about how to position the bars (above, below, to the side) relative to the subVIs. I think just as long as the coloring acts as a "mask" (that is, you can easily make the bars visible and invisible, and you can't interact with them), then it should be pretty easy to incorporate them without sacrificing visibility of the code.

I prefer showing the actual data instead of the slider bars... no sense hiding data. If you want a graphical approach, maybe you could set a 'maximum time' and 'maximum memory' value to each VI and then the color of the text could change as you approach and surpass those limits.

-John SullivanProblem Solver

You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.