6.1. Initial State: Correct, Measurable Program, Good Test Case

The first step is to make sure the program is running correctly, and that it produces some measurable output that can be used to verify the correctness of later versions of the program.

As far as possible, try to devise a test case with predictable, repeatable behavior, which is independent of execution speed (since the sampler will impose a slowdown).

It will be difficult for a programmer to ensure unmodified behavior, and to determine whether he has achieved any performance improvements if these conditions are not met. Real time programs, in particular, may start experiencing altered behavior if the processor load is increased. There is no universal solution for this, but some real time applications can be changed to reduce their time-base corresponding to the apparent slowdown.

Some applications run from start to completion and their execution is easily repeatable. These are the simplest applications to analyze. Others run more or less continuously, and are rated on number of transactions per second, average throughput or something similar. Establish a criteria for starting and stopping acquisition of fingerprint data, which can be timed, measured, and above all, repeated.

Some source code transforms change the number of memory operations. To be able to compare cache miss behavior of a run before the change with a run of the changed code, there are a few options. It is possible to compare miss and fetch ratios, but if an algorithm change alters the number of accesses as well as the number of misses, the calculated miss ratio will change in an unpredictable way. Under repeatable circumstances, it makes more sense to compare the absolute number of misses before and after the algorithm change.

If the test case is not absolutely repeatable, it will be difficult to correlate two measurements of the absolute number of misses or fetches. In such cases it makes more sense to look at ratio numbers, as they are less affected by exact execution times.

[Tip]Tip
Ensure correct execution.
[Tip]Tip
Devise a repeatable test case.
[Tip]Tip
Take a reference measurement of the the execution time.