Performance experiments
Quick answer
A controlled performance experiment compares a baseline with a candidate under equivalent conditions. Measure the same outcome, repeat trials and verify correctness before claiming an improvement.
A faster median can coexist with a worse slow-tail latency. Keep inputs, resource limits and correctness checks fixed, report multiple trials and compare the distribution rather than selecting the best single result. Change one variable at a time when practical.
Prepare the practice environment
Run python3 lab-fixtures/performance/setup.py from the extracted root as an ordinary user. Enter the printed fresh private path and check pwd. Use fresh fixtures, Bash with set -e -o pipefail, LC_ALL=C and umask 077. Run each snippet in a separate Bash process, not your interactive shell. Only private files are used; optional examples require an authorized snapshot VM. Do not change live monitoring or services. All supplied records are fictional; live read-only header checks do not retain measurements. Review the lab guide.
Prerequisites
Review: Tracing and profiling tools.
How it works
Define a hypothesis and a user-relevant metric, record versions, input size, environment, CPU limits, cache state and concurrency. Keep one intentional change at a time; alternate runs if background drift matters. A warm-cache comparison must not be confused with a cold-cache comparison. Use median and spread for repeated trials; p95 requires a stated estimator and enough observations. Bash time -p reports real (elapsed), user and sys CPU seconds on stderr. CPU time can exceed elapsed time with parallel work. For a latency improvement, (baseline minus candidate) divided by baseline gives fractional reduction; speedup is baseline divided by candidate. Check output equality and failure rates; a faster wrong result is not an improvement. The CSV is fictional and the small timing example checks format only, not a benchmark.
Try the examples
The fictional repeated trials show a median reduction of 20%, or 1.25x speedup. They do not prove real performance gains.
Expected stdout:
baseline median 100 ms; candidate median 80 ms; reduction 20.0%; speedup 1.25x{ time -p /bin/true; } 2>&1 | awk '$1=="real" || $1=="user" || $1=="sys" {print $1}'Only timing labels are retained because durations depend on the machine.
Expected stdout:
realusersyscmp expected.txt candidate.txt && printf 'output verified\n'The sample output is byte-identical. Real experiments also require error and side-effect checks.
Expected stdout:
output verifiedCommon mistakes
Do not compare different inputs, cherry-pick the fastest run, or tune kernel settings without a measured hypothesis and rollback plan.
Practice
Use the fixture to report median, range and relative reduction for both sets. Design a repeatable comparison with equal inputs and a correctness gate; explain when you would reject the candidate.
Related references
Study: time. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Performance experiments — Knowledge Check
Apply performance-analysis concepts to synthetic fixtures and VM-only scenarios.
Baseline 100 ms and candidate 80 ms imply what reduction?
What is speedup for those times?
What if the candidate is faster but wrong?
Why repeat trials?