Tip – Automated Metrics
Monday, October 13th, 2008Several people have asked me lately about automating metrics with Understand 2.0. There are two quick ways to automate metrics, as a scheduled activity and via the command line:
Several people have asked me lately about automating metrics with Understand 2.0. There are two quick ways to automate metrics, as a scheduled activity and via the command line:
I was walking down to the kitchen to get my afternoon cookie and I met another of our engineers. He asked “hey, how would I use Understand to clean up a class of functions that are no longer used?”. I thought for a bit and said “piece of cake”.
In short…. use the entity filter window to filter on “unused functions”, turn entity->long names on, then type in the name of the class. Done.
Here are the steps…. First select the “Unused Functions” filter in the Entity Filter window:

We are busy internationalizing important messages in Understand 2.0 so that they can be translated into Japanese. This involves a lot of changes that are identical. For instance, all translatable strings have to be turned into functions that go through a translation function “tr()” that will table lookup the string to the corresponding Japanese translation.
So take for instance this section of code:
procedure Buffer_Demo is
EOL : Character renames ASCII.LF;
Text : constant String
:= “Four score and seven years ago our fathers brought forth,” & EOL &
“upon this continent, a new nation, conceived in liberty,” & EOL &
“and dedicated to the proposition that `all men are created equal’.”;
I’ve got to make it look like this:
procedure Buffer_Demo is
EOL : Character renames ASCII.LF;
Text : constant String
:= tr(“Four score and seven years ago our fathers brought forth,”) & EOL &
tr(“upon this continent, a new nation, conceived in liberty,”) & EOL &
tr(“and dedicated to the proposition that `all men are created equal’.”);
Fortunately, Understand 2.0 can record editor macros that make repeated tasks easy and possibly fun.
Here is how…
Understand 2.0 Favorites lets you organize locations (file/line#) or entities (e.g function foo, file foo.cpp) into a named folders.
Favorites can be “project favorites”, where they are only applicable to the .udb file open when you made them, or “all project favorites”, which are available no matter what project you have loaded. The “All Projects” variety is useful to me since I have dozens of projects of largely the same source that I use for different testing/evaluation purposes.
Favorites are shown in the “Favorites” window, which you can show by clicking on the
toolbar (or by Windows->Favorites).
I have my favorites organized into three folders:

I give a lot of web and in-person demos of Understand, “Good Demos” is where I store classes, functions, and files that help me simply explain the kinds of things Understand does. For instance, here I have classes and functions and a “butterfly” view with the [x] Sync box checked. In a demo, I can just click on the favorite and see the graph update auto-magically.
“Interfaces” provides a handy spot to stash a quick way to see the API’s we often work against here. For instance, the “Understand database API (udb)” or “Change API”. If I need to know the UDB API details, I just click on it and up comes the source:
“ToDo” stores places I want to take a peek at again later. Often this is when I find a spot, or a user reports a spot, where a crash or bug can be replicated. It is empty now, but let’s pretend I want to come back and look at a spot here in the UDB interface.
First I just click in the editor where I want to remember. Then pull down the Favorites toolbar menu:

It asks me to place the favorite, and I specify “All Projects” and put it inside “ToDo”:
It is now in my Favorites and I can visit it just by double clicking on it:


Our most frequently asked support question goes something like this: “I see the graphs on your website, but how do I get them in Understand?”. With Understand 1.4 the only way to get a call tree other other graphical view was to right click on the function and choose “Graphical Views->Call Tree”. That is totally obvious to some new users and to others a huge mystery. And that is understandable. Not everybody has used applications with right click context menus.
Understand 2.0 keeps the context menus, but also adds a new Graph Toolbar:

This toolbar item updates whenever you click on an entity anywhere in source or any of Understand’s graphical or other informational views.
To get a graph, just pull down the menu:

and the graph will pop right up.

Our hierarchy charts have always shown one relationship, for instance “Call”, on a chart. We’ve just introduced “Butterfly” charts, which will show two relationships that are the inverse of each other. For instance, “Call and CallBy”, “Include and Include By”, “Derived and Derived By”.
For instance, here is a butterfly chart for a function (click on it to see it bigger):
The function queried was “add_data_in_datablock”. Note that it is in the middle, with calls it makes to the right, and those it is called-by to the left.
These graphs are available for every entity that we have hierarchical graphs for.

We just added this toolbar section to the Understand 2.0 toolbar:

It controls workspace splitting. Here are some examples. Click on them to see them bigger.
Single document view workspace:
Split workspace – horizontal & vertical
In Using Understand with an external editor – SlickEdit I explained how to hook up Understand to run with SlickEdit. As a follow up, here are the commands to setup the same Understand menu inside of EMACS, Visual Studio, and Vi. Do let me know if I made any mistakes here since I’m not an expert on these editors.
I’ve covered making Snapshots from the Current Database and by checking out source to an alternate location in earlier posts. Now I’m going to tell you the EASY way to do it…. Just use TrackBack.

Assuming you have had TrackBack B443 or later monitoring your source trees, you can recreate the state of any monitored directory at any time. This includes file modification, file existance, file renaming, everything.
User tools are a convenient way to quickly access external tools or other applications. In an earlier post, Ken shared his SVN User Tools, which provide quick access to version control commands right inside the application. If you use a different version control system, or want to launch another application, you’ll need to know how to make your own user tools.