Knowledge check

Use these questions to check the complete investigate–measure–change workflow. They are included in the final episode’s time.

Questions

  1. Why should a correctness oracle be established before benchmarking?

  2. What is the difference between tottime and cumtime in a cProfile report?

  3. When is line_profiler preferable to profiling the whole application again?

  4. Name four facts required to make a performance result assessable by another person.

  5. Why should IceCream calls and verbose diagnostics be disabled before a benchmark?

Answers

  1. It prevents a faster but changed or wrong result from being accepted and fixes the useful work being compared.

  2. tottime excludes subcalls; cumtime includes time in the function and its descendants.

  3. After function-level evidence has identified a small Python function whose individual lines need investigation.

  4. Any four of: revision/environment, machine or allocation, input/workload, correctness result, timing boundary, warm-up, repetitions, raw samples, statistic, and limitations.

  5. Output and value formatting add work, alter execution, and may disclose sensitive values.