ANTS Performance Profiler 7

Integrating ANTS Performance Profiler in a test procedure

Integrating ANTS Performance Profiler in your existing automated test framework ensures 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, you perform three general steps:

  1. Profile your application from the command line, saving 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 you only need method-level timings, or whether you want to run the tests in sampling mode.
  2. Choose whether you prefer 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 saving results to a CSV file, run:

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

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.app7results"

Note that in these examples, the .app7results file is also saved. The .app6results 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.

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

2. Read 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. Make 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 assert that the time taken by exampleMethod() must not be longer than 0.02 seconds + 20% (0.024 seconds).

In the NUnit test framework:

Assert.Greater(0.024, double exampleMethodTime);

Didn't find what you were looking for?