ANTS Performance Profiler 10

Integrating ANTS Performance Profiler in a test procedure

You can integrate ANTS Performance Profiler into your existing automated test framework to ensure that you are alerted whenever a change is made that would adversely affect your application's performance.

To integrate ANTS Performance Profiler in automated tests, perform three general steps:

  1. Profile your application from the command line and save the results to a CSV or XML file.
  2. Read the results into the test harness.
  3. Make assertions about the data you have read.

1. Profiling your application from the command line

For automated tests, you do not need much detail in the results. We recommend that you either profile using method-level timing only, or that you profile in sampling mode.

To profile your application from the command line:

  1. Choose whether to record method-level timings or whether you want to run the tests in sampling mode. 
    For more information about profiling modes, see Choosing a profiling mode.
  2. Choose whether you want to save results in CSV or XML format.

    To assist your decision, see Examples of CSV and XML results files.

  3. Set the command line arguments to reflect your choices.

For example, to profile SimpleApp.exe, using method-level timings (the default) and save the results to a CSV file, run:

Profile.exe /e:"C:\testing\SimpleApp.exe" /csv:"C:\testing\results.csv" /data:"C:\testing\results.app8results"

To profile SimpleApp.exe using sampling and saving results to a XML file, run:

Profile.exe /e:"C:\testing\SimpleApp.exe" /sm /xml:"C:\testing\results.xml" /data:"C:\testing\results.app8results"

In these examples, the .app8results file is saved in addition to the XML file. The .app8results file is not used for integrating with the test procedure, but saving it ensures that you can investigate any problems without needing to profile your application again by opening it in ANTS Performance Profiler.

For a full list of arguments you can use when profiling at the command line, see Profiling from the command line (API).

2. Reading the results into the test harness

Write a simple command line application to read the CSV or XML data.

For information on how to read XML data in C# using the XMLTextReader class, see How to read XML from a file by using Visual C# (Microsoft documentation).

3. Making assertions about the data you have read

Using your automated test framework, ensure that the performance data is within a reasonable bound for each method that you are interested in.

For example, if you know from experience that exampleMethod() normally takes about 0.02 seconds of CPU time, you may assert that the time taken by exampleMethod() must not be longer than 0.02 seconds + 20% (0.024 seconds).

In the NUnit test framework this is:

Assert.Greater(0.024, double exampleMethodTime);

Exporting results to HTML, XML and CSV files

You can save profiling results to HTML, XML, and CSV files. For more information about saving profiling results in different formats, see Saving profiling results.

Didn't find what you were looking for?