Chapter 21 — Measuring contractor performance
Lesson map
Lesson 21 published. Map, example, EX061.
flowchart TD
N0["Learning outcomes"]
N1["21.1 The target"]
N2["Lab — Emergency repairs within twenty-four hours for"]
N3["21.2 Results"]
N4["21.3 Fair comparison"]
N5["21.4 Using the results"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5
N5 --> EX["Worked example"]
EX --> Q["Exercise EX061"]
Logical drawing
flowchart LR
N0["Learning outcomes"]
N1["21.1 The target"]
N2["Lab — Emergency repairs within twenty-four hours for"]
N3["21.2 Results"]
N4["21.3 Fair comparison"]
N5["21.4 Using the results"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> Q["EX061"]
[Learning outcomes]
|
v
[21.1 The target]
|
v
[Lab — Emergency repairs within twenty-four hours for]
|
v
[21.2 Results]
|
v
[21.3 Fair comparison]
|
v
[21.4 Using the results]
|
v
[Worked example] --> [Exercise EX061]
Learning outcomes
You will (1) compute performance against a time target; (2) compare contractors with medians and shares; (3) present results fairly.
21.1 The target
Calder Valley requires emergency repairs to be completed within twenty-four hours of the tenant's first report. Two contractors carry out emergencies: one in the north of the area and one in the south. Ravi measures each contractor's performance using full timestamps, following the lineage fixes from chapter 13, and the first-report time field added in chapter 9. He calculates the share completed within twenty-four hours and the median time, which shows a typical job rather than being distorted by a few very long ones.
Lab — Emergency repairs within twenty-four hours for two synthetic contractors
"""Share of synthetic emergency repairs completed within 24 hours, by contractor (stdlib only)."""
import random
random.seed(4)
for name, mean in [("North contractor", 10), ("South contractor", 17)]:
h = [random.expovariate(1/mean) for _ in range(800)]
print(f"{name}: within 24h {100*sum(x <= 24 for x in h)/len(h):.1f}%; median {sorted(h)[400]:.1f}h")
Run with python3 lab_emergency.py. Verified output:
North contractor: within 24h 89.1%; median 7.2h
South contractor: within 24h 74.2%; median 12.5h
21.2 Results
The lab simulates eight hundred emergency jobs for each contractor. The north contractor completes 89.1 percent within twenty-four hours, with a median of 7.2 hours. The south contractor completes 74.2 percent, with a median of 12.5 hours. Ravi notes that the gap is clear in both measures, so it is unlikely to come from a handful of unusual jobs. He presents both measures together, because a share alone hides how far from the target late jobs fall. He shows the two contractors side by side in a short table for the manager.
21.3 Fair comparison
Before presenting, Ravi asks whether the comparison is fair. The south area is more rural, with longer travel distances, which could explain some of the difference. He checks whether job types differ between areas in the synthetic data and finds a similar mix. He includes the travel caveat in his report and suggests comparing jobs within similar distances in a follow-up. Ms. Moreau notes that technologists should anticipate fairness questions rather than leaving managers to discover them later. The manager welcomes the caveat.
21.4 Using the results
The repairs manager meets the south contractor with Ravi's results. The contractor explains that it has only one emergency team overnight. Calder Valley and the contractor agree to add a second overnight team for a trial period, with monthly measurement using the same script. Ravi documents the measurement method in the dictionary so both parties trust future figures. He notes that agreed measurement methods turn performance discussions from arguments about numbers into discussions about improvement. The trial begins the following month, with results reviewed jointly.
Worked example
Ravi measures emergency repairs with full timestamps, finding north 89.1 percent and median 7.2 hours versus south 74.2 percent and 12.5 hours, considers rural travel and supports a trial second overnight team.
Synthetic case. Jobs are synthetic; outputs come from lab_emergency.py.
Errors and limits
Reporting only a share hides how late the late jobs are.
Exercises
- EX061 — South share. What share did the south contractor complete within twenty-four hours? Rubric: 3 = 74.2%;; 2 = partly correct;; 1 = wrong;; 0 = none.
- EX062 — North median. What was the north contractor's median time? Rubric: 3 = 7.2 hours;; 2 = partly correct;; 1 = wrong;; 0 = none.
- EX063 — Overnight cause. What did the south contractor reveal? Rubric: 3 = only one emergency team overnight;; 2 = partly correct;; 1 = vague;; 0 = none.
Continue studying — lesson 21 (chapter 21 of 30)
← Chapter 20 · Course chapter index · Chapter 22 →
Continue to the next authored lesson.