# Do performance measurements need to be accurate and precise?

Like many performance questions the answer is “it depends”.

This question is one of the “simple” questions – which most people get wrong. For example you can have a very precise answer which is inaccurate.

## Precision

People often give the wrong precision. For example

• What is the difference between 1 and 1.0?
• What is the difference between 999 and 1000, and 1000.0?

### What is the difference between 1 and 1.0?

With decimal points you can tell the precision from the number of digits after the decimal point.

• The value 1 is a number between 0.5 and 1.49, with a range of almost 1
• the number 1.0 is between 0.95 and 1.049. with a range of almost 0.1

### What is the difference between 999 and 1000, and 1000.0?

With numbers without a decimal point, the convention is the number of significant non zero digits.

• 999 is in the range 998.5 to 999.49 a range of almost 1
• 1000 has one significant digit – so this can represent a number in the range 500 to 1490, a range of almost 1000!
• 1000.0 represents a number in the range 999.5 to 1000.49 a range of almost 1

### Is precision important ?

If you have a set of measurements with values 9.6 9.8,9.9, 10.0, 10.1, 10.2 10.4 the average is 10.0. Saying the average is 10.0 is misleading as it implies the value is between 0.995 and 10.049. The value have a spread – and in this case, saying the value is 10, is better than saying 10.0. You could say 10.0 ± 0.4 to give an even better answer.

## Is accuracy important?

Depending on what you want to deliver from your measurements, the CPU figures you collect may not be accurate enough – or they may be good enough not to worry about.

### Why are the CPU used figures inaccurate?

There is a gap between what is reported and what is actually used. For a high proportion of measurements the reported CPU is accurate enough. For some measurements you have to factor in this missing usage.

Below is a simplistic view of work being dispatched on an operating system.

• The dispatcher scans the list of work to find the next work to dispatch
• Get “Before – clock time”
• Get “Before – processor CPU time”
• Invoke the work. It does calculations, starts an I/O request and waits for the response, by returning control to the dispatcher
• Get “After – processor CPU time”
• Get “After – clock time”
• Calculate the difference in clock times and accumulate this in the “work – active time”
• Calculate the different in the processor CPU times to determine how much CPU time was used for the work, and accumulate this in the “work – CPU time”
• The dispatcher scans the list of work to find the next work to dispatch
• etc

The elapsed time figures, and the CPU time used are both accurate, but they do not include the elapsed time or the CPU time the dispatcher took to initiate the work and update the statistics. We can give a better estimate of the true costs.

When running a measurement z/OS can report the CPU used by each engine across the duration of the measurement. We might have

• Total CPU used across the duration 50 seconds
• Total CPU used for job A 40 seconds
• Total CPU used for job B 9.5 seconds
• Difference in CPU 0.5 seconds

A common way of allocating this “missing CPU” is to allocate it to the jobs depending on the amount of CPU the jobs used in the period. Job A would have 40 + (0.5 *40/50) = 40.4, and job B would have 9.5 + (0.5 * 9.5/50) = 9.6, a total of 50.

Is this completely accurate? – no but it is more accurate than before!

### Is this important?

If you want to see the effects of defining an index on an SQL table, a throughput improvement of 100 times or two time, it is good enough to say yes – it improved performance. This does not need to be precise or very accurate.

If you have enhanced your program to remove bottlenecks and can show the CPU per transaction has dropped from 1.2 to 1.1 units then this relative comparison is valid – even if the cost is not entirely accurate.

If you want to give numbers for other people to use, such as the cost of 1000 transactions a second is 1.2 seconds of CPU on this configuration, you need to ensure the figures are accurate.

### Do performance measurements need to be accurate and precise?

For many measurements the numbers do not need to be very precise, and the accuracy may be good enough.