Skip to content

Export & track metrics over time

Metrics can be exported using Understand's built-in metric export, or with reports such as Line Metrics or Complexity Metrics. This page documents the built-in metric export. See Export & script reports for how to export reports.

Understand's built-in metric export creates a CSV file with each entity as a row and each metric as a column. Users select which metric columns to export, and any entity that has a value for at least one selected metric gets exported.

Export from the GUI

The export is accessible from the GUI from two locations. From the top level menu bar, use Metrics → Export Metrics. Or, open the Metrics Browser (Metrics → Browse Metrics) and click the Export Metrics icon.

This opens the "Export Metrics" dialog.

The Export Metrics dialog: an Output File path at the top, a checkable list of metrics with Code Lines and Cyclomatic Complexity checked, and below it the Options section with Write Column Titles, Include Entity Unique Name to track changes over time, Show Function Parameter Types, Show Declared In File, and File Name Format.
The Export Metrics dialog: pick the output file, check the metrics to export in the order you want them, then set the options below the list.

Selecting Metrics

Choose which metrics get exported by checking them. The order is the visible order shown. You can customize the order by drag-and-drop, or by using actions in the toolbar: Move to Top, Move Up, Move Down, and Move to Bottom. You can also apply a sort using the Sort menu in the toolbar.

Only enabled metrics that apply to the current project will be shown in the list. Use the Configure toolbar action to configure enabled metrics. An enabled metric may still be absent from the list if it isn't applicable to the project. For example, the Const Methods metric is a C++ only metric and so it will only appear if C/C++ is a language in the current project.

Once you've built the list of metrics you want exported in your desired order, you can export the list to a text file with the Export icon. The list can then be imported with the Import icon or used from the command line.

Tracking over time

Additional options are available below the metrics list. The "Include Entity Unique Name to track changes over time" is one way to track changes over time. It adds a column to the export containing a unique identifier for each entity. Turn this on if you are planning to diff CSV exports.

Simplest long-term tracking

Run und metrics on every build and archive the CSVs - for example one per tag or per nightly run - then chart the columns you care about in your spreadsheet or CI dashboard. The Entity_Uniquename column lets you follow a single function across runs.

Another method of tracking over time is to use comparison projects and diff metrics. See Compare two versions of a project.

Waiting for the export

The export can take some time, especially for slower metrics like Coupled Classes. See Rank & compare entities by a metric for slow metrics and alternatives.

Because it is slow, it runs on a background thread. You can see the progress or cancel it from the global progress symbol in the top right. Note that if you analyze your project, the export will be automatically cancelled.

Export from the Command Line

The same export is available from the command line with und metrics. From the GUI, you can use the API button in the "Export Metrics" dialog to generate a command line for you.

Unlike the GUI, the command line allows access to all metrics, enabled or not. So you can build a list of metrics without worrying about the GUI enabled settings. Note that for the command line, metric ids (not names) are always used. So, if you want to export Code Lines and Cyclomatic Complexity, the command would use their respective ids:

und metrics -metrics CountLineCode Cyclomatic output.csv myProject.und

For long lists of metrics, it may be more convenient to save the list to a file. You can export a list from the GUI's "Export Metrics" dialog or build your own with one metric id per line. An example metrics file is:

# Comment lines are allowed.
CountLineCode
Cyclomatic

And the corresponding und command, assuming the example was named sample_metrics.txt:

und metrics -metrics @sample_metrics.txt output.csv myProject.und

Next Steps

For the visual, project-wide view of where risk concentrates (Treemap and Heatmap), see Where is my risky / complex code?. For metric meanings, see Interpret key metrics and What does Cyclomatic Complexity mean?.