Efficiency measurement
Design a fair measurement
Efficiency measurement relates resource use or environmental impact to useful service output. Define the functional unit, for example one validated report delivered before its deadline, and the system boundary before comparing designs. Count only successful outputs; include failed attempts and retries in the resource numerator. Use matching observation intervals, workload mix, quality, latency, recovery and security requirements. Keep raw counters and their provenance.
The local model below uses whole vCPU-hours as a simplified proxy. Real systems may have fractional hours and multiple resource dimensions. It does not convert CPU utilization into electricity or emissions.
Establish a reproducible measurement plan
- Record workload version, traffic mix, fixed observation period, service targets and approved regions. Include compute, storage, transfer, queueing, retries and shared dependencies.
- Collect total resource consumption and successful units; identify measurement source and whether values are metered or allocated. Repeat trials to assess variation. Compare p95 latency and error rate with the baseline.
- Where energy is available, document meter location, time resolution and overhead inclusion. If it is not, label utilization or resource-hours as proxies.
- For carbon calculations, obtain a documented factor for the right region and time, accounting approach, units and method revision; preserve uncertainty. Do not make up regional values or silently substitute another provider's figures.
- Keep policy, privacy, retention and recovery gates. Review candidate changes, roll out gradually, then verify the same metrics and reverse if service requirements fail.
Calculate only supported quantities
The Software Carbon Intensity (SCI) specification v1.1.0 describes an intensity over a functional unit R: SCI = (O + M) / R, where O is operational emissions and M is allocated embodied emissions. A simple electricity model uses O = E × I for energy E (kWh) and relevant carbon intensity I (gCO2e/kWh). Both terms must have compatible units and scope. This is not a complete implementation of SCI; consult the specification for boundary, quantification and reporting requirements. If I or M is unknown, the corresponding full intensity is unknown, not zero. No numerical regional factors are provided in this lab.
For a measured IT energy of 10 kWh and a hypothetical facility PUE of 1.2, facility energy under that model is 12 kWh. This arithmetic is valid only if the PUE applies to the same period and equipment boundary. With 1,000 completed reports this is 0.012 kWh/report. It gives no carbon figure without the appropriate factor. If an actual report gives already allocated emissions, do not multiply them by an electricity factor again. SCI specification.
Run the local comparison
Run with Python 3 (standard library only). The checks are deliberately explicit booleans supplied by a trusted local fixture; they are not a security or compliance verifier. Fraction preserves exact arithmetic. The returned tuple contains baseline intensity, candidate intensity, per-unit direction and total direction. Both designs must satisfy the same gates; a failed constraint blocks comparison.
from fractions import Fraction
def compare(base, candidate): # Model inputs: successful reports, vCPU-hours, deadline met, # quality met, residency met, recovery met, same boundary/window. for row in (base, candidate): reports, hours, *checks = row if type(reports) is not int or reports <= 0: raise ValueError("positive report count required") if type(hours) is not int or hours < 0: raise ValueError("nonnegative whole vCPU-hours required") if len(checks) != 5 or any(type(x) is not bool for x in checks): raise ValueError("five explicit boolean checks required") if not all(base[2:]) or not all(candidate[2:]): return "NOT COMPARABLE" before = Fraction(base[1], base[0]) after = Fraction(candidate[1], candidate[0]) return (str(before), str(after), "lower" if after < before else "higher" if after > before else "equal", "lower" if candidate[1] < base[1] else "higher" if candidate[1] > base[1] else "equal")
baseline = (1000, 80, True, True, True, True, True)optimized = (1000, 60, True, True, True, True, True)expanded = (2000, 120, True, True, True, True, True)print(compare(baseline, optimized))print(compare(baseline, expanded))print(compare(baseline, (1000, 30, True, True, False, True, True)))Expected output:
('2/25', '3/50', 'lower', 'lower')('2/25', '3/50', 'lower', 'higher')NOT COMPARABLE2/25 is 0.08 and 3/50 is 0.06. The expanded design is more efficient per report but uses more total resources. The last candidate violates residency. A lower resource total does not justify a policy violation. Nothing in this program contacts a cloud service.
Quantify uncertainty and economics separately
If 60 vCPU-hours is an observed estimate within 55–65 and 80 within 75–85 for identical report counts, the modeled reduction spans approximately 13.3% to 35.3% using extreme endpoints (1 − 65/75 and 1 − 55/85). This is an assumption-based sensitivity range, not a statistical confidence interval. Overlapping ranges can make a ranking inconclusive. Record repeated measurements, sampling bias and any missing shared resources.
For an explicitly fictional price of 5 cents per vCPU-hour, the compute-only estimate is 400 cents before and 300 cents after. If added storage/transfer costs 140 cents, the candidate costs 440 cents in the simplified model: less compute, more total cost. No live pricing or emissions savings are guaranteed. Compare full cost, total usage, intensity, quality and environmental evidence separately.
Common mistakes and practice
Do not confuse provisioned with consumed resources, compare different functional units, discard failed work from the numerator, treat missing factors as zero, sum alternative market/location totals, or use corporate reports to rank specific workloads. Keep dated evidence and units beside each result.
Practice: compare 2,000 reports using 120 hours with the baseline; test a failed deadline and zero outputs. Write a decision note stating which claims are supported, what energy and factor data are missing, and how you would verify changes and roll back. The next chapter builds safe cloud API automation with deterministic stubs.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Efficiency measurement — knowledge check
Choose the best answer for each offline scenario.
Which denominator fits a report workload?
If carbon intensity is missing, what is the correct full SCI result?
What happens when 2,000 reports consume 120 hours versus 1,000 consuming 80?
When is multiplying IT energy by PUE appropriate?
What does the local model do with a failed residency check?