Empirical Performance Measurement: Fair Tests and Careful Conclusions

Empirical Performance Measurement uses observations from running programs to compare their resource use under specified conditions. You use it when choosing between implementations that produce the same required result. A timing experiment answers a concrete question about particular inputs, software settings, and hardware. It provides evidence about those conditions; it does not establish performance for every possible input.

Decide what the measurement includes

Begin with the decision you need to make. Are you comparing one lookup after a data structure is ready, or the complete time to build that structure and answer a request? Both questions are useful, but they require different timing boundaries.


Choose inputs that reflect the intended workload, including their sizes and relevant characteristics. Two collections with the same number of entries can still produce different timings if their ordering, repeated values, or query patterns differ. Give both implementations the same logical inputs and verify that their outputs satisfy the same correctness requirements.


Decision

Include in the timed region

Usually prepare separately

Compare ready-to-use operations

The same sequence of operations

Input generation and structure construction

Compare complete jobs

Required loading, construction, and processing

Test-data creation unrelated to the job

Compare warmed request handling

Requests after the chosen warm-up

Startup and excluded warm-up work


Use the same timing boundary for both implementations. If an operation changes its input, restore an equivalent starting state before each trial. Otherwise, later trials may perform different work.

Collect timings that you can interpret

Use a monotonic clock appropriate for measuring elapsed time. Keep the machine, software versions, compiler settings, and competing background activity as consistent as practical. Record these settings so someone else can understand the comparison.


Very short operations can be difficult to time individually. Run a batch of kk operations and divide the elapsed batch time by kk:


toperation=Tbatchk.t_{\text{operation}}=\frac{T_{\text{batch}}}{k}.


This is the average time per operation within that batch, including any costs still inside its boundary. Batching reduces the relative impact of reading the clock, but it does not automatically remove loop overhead. Subtract separately measured overhead only when an additive, unchanged overhead model is justified.


A timing boundary separates input preparation from the operations being measured and subsequent result checks.


For warmed execution, run excluded warm-up work before collecting measurements. Warm-up allows effects such as runtime compilation and recently accessed data remaining in fast memory to settle. For a startup-sensitive task, measure startup instead of silently excluding it. Ensure computed results are used observably so optimization does not remove the intended work.



Repeat the measurement. Report the number of trials, a suitable summary such as the median, and the observed spread. After sorting the timings, the median is the middle observation for an odd number of trials, or the average of the two middle observations for an even number of trials. It reduces the influence of an unusually long trial but does not explain why that trial occurred.

Compare results on a shared basis

Speedup is the reference time divided by the candidate time for the same work. Using comparable summary times gives:


S=treferencetcandidate,time reduction=treference−tcandidatetreference×100%.S=\frac{t_{\text{reference}}}{t_{\text{candidate}}}, \qquad \text{time reduction}=\frac{t_{\text{reference}}-t_{\text{candidate}}}{t_{\text{reference}}}\times100\%.


A speedup above 11 favours the candidate. Speedup is dimensionless because the time units cancel. Percentage time reduction uses the reference time as its denominator; it is a different quantity from the speedup factor.


A small difference compared with the run-to-run spread deserves further investigation. Repeat under controlled conditions and inspect the individual timings rather than claiming a decisive advantage from one favourable trial. Measure several relevant input sizes before making a recommendation across a workload.



State conclusions within the tested workload and environment. Timing evidence alone also says nothing definite about an implementation's memory use; measure that resource separately when it matters.

What to remember

  • Define the workload, correctness requirements, and timing boundary first.
  • Repeat comparable trials and report both typical time and variability.
  • Distinguish time per operation, speedup, and percentage time reduction.
  • Include startup or setup whenever the intended use requires it.

Example: Comparing lookup timings and complete jobs

A product catalogue service is testing two lookup implementations. A batch is a group of operations measured together; each batch here contains the same sequence of 5000 read-only lookups. Both implementations return the required results. Construction and input preparation are excluded from the lookup timer, warm-up is complete, and execution order alternates on the same machine.


The five batch times for A are 6262, 6060, 6363, 6161, and 59 ms59\ \text{ms}. For B, they are 4646, 4444, 4545, 4747, and 43 ms43\ \text{ms}. Treat remaining timing overhead as negligible for this example.


Two rows of points show five measured lookup batch durations for each implementation.


a) Use each implementation's median batch time to estimate its time per lookup. Give both results in microseconds to one decimal place.


Sort the times to identify the middle observation in each set of five. A's sorted times are 5959, 6060, 6161, 6262, and 63 ms63\ \text{ms}, so its median is ________. B's sorted times are 4343, 4444, 4545, 4646, and 47 ms47\ \text{ms}, so its median is ________.


Divide each median batch time by 5000. Convert milliseconds to microseconds using 1 ms=1000 μs1\ \text{ms}=1000\ \mu\text{s}:


tA=61×10005000=12.2 μs,tB=45×10005000=9.0 μs.t_A=\frac{61\times1000}{5000}=12.2\ \mu\text{s}, \qquad t_B=\frac{45\times1000}{5000}=9.0\ \mu\text{s}.


The estimated times per lookup are 12.2 microseconds for A and 9.0 microseconds for B. These values are batch averages calculated from the median batch durations, rather than medians of individually timed lookups.


b) Using A as the reference, calculate B's speedup factor to two decimal places and percentage time reduction to one decimal place.


The median batch-time difference is ________. Divide the reference time by the candidate time for speedup:


S=6145=1.35555…≈1.36.S=\frac{61}{45}=1.35555\ldots\approx1.36.


For percentage time reduction, divide the difference by the reference time. The unrounded fraction saved is approximately ________:


R=61−4561×100%=26.2295…%≈26.2%.R=\frac{61-45}{61}\times100\%=26.2295\ldots\%\approx26.2\%.


B has a speedup factor of 1.36 and a time reduction of 26.2% for the measured lookup batches. Both comparisons use the same work and the same reference implementation.


c) A separate complete-job test must construct a catalogue and then perform one batch of 5000 lookups. Construction takes 18 ms18\ \text{ms} for A and 90 ms90\ \text{ms} for B. Assume construction time and the median lookup-batch time add exactly, with no other costs. Which implementation has the smaller estimated complete-job time, and by how many milliseconds?


The end-to-end time is the time for all stages included in the complete job. Here, construction is included once before the lookup batch, so add it to each implementation's median lookup time:


TA=18+61=79 ms,TB=90+45=135 ms.T_A=18+61=79\ \text{ms}, \qquad T_B=90+45=135\ \text{ms}.


The estimated totals are ________ for A and ________ for B. Subtract the smaller total from the larger total to find the difference:


135−79=56 ms.135-79=56\ \text{ms}.


A has the smaller estimated complete-job time, by 56 milliseconds. B wins the lookup-only comparison, but its larger construction cost reverses the choice for this one-batch job under the stated additive model.

A developer wants to compare only the lookup operation after construction in two dictionary implementations. Both return correct results. Which experiment best supports this comparison?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A team compares two implementations of a document-processing service. Match each performance metric to the description of what it measures during a specified test interval.

Match each term
A.

Number of jobs completed per unit of measurement time

B.

Total time the CPU cores spend running the program's instructions, summed across cores (excluding time spent waiting)

C.

Wall-clock duration between the selected start and finish events

D.

Largest amount of storage the program holds simultaneously at any single instant during the measured interval

Peak memory use

Elapsed time

Throughput

Processor time

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A parser processes 6000 records in a measured batch time of 0.936 s0.936\ \text{s}. A separately measured benchmark harness contributes 0.036 s0.036\ \text{s} per batch. Assume this overhead is additive and unchanged when parsing occurs. Estimate the average parsing time per record, excluding harness overhead, in microseconds to one decimal place.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Extra Practice