Skip to content

Sample work · Code & Bugs

Performance profiling: measuring the bottleneck, fixing it, and verifying the result

A slow demo program: cProfile identifies the function where the time is spent, the fast version provides the same result value by value, and the time is measured repeatedly. An optimization with a different result is rejected.

Sample work (demo), not a client job. Built as a trial task with invented example data; the check figures below come from the automatic test run and are not polished.

What was built

  • The profiler shows the location, nothing is assumed
  • Result of the fast version is identical, even for edge cases
  • Smallest time from several runs
  • Program invented

Download programm-langsam.py Download programm-schnell.py

How it was checked

Automatic test run on 2026-10-31, taken from the log (test data invented, figures measured):

  • Demo program: cProfile identifies double as the bottleneck, factor 85 faster with the same result (23 ms to 0.3 ms, smallest of five runs)
  • Incorrect optimization rejected
  • 9 checks

Limits

What this sample does not cover, so nobody expects more:

  • Times depend on the computer and data volume; the factor applies to the demo data
  • For client code, measurements are taken with their actual inputs; changes are only adopted if tests remain unchanged
  • No load testing of a web application on the network

Something like this for your business?

Describe briefly what you need. You get a fixed price before I start; nothing happens without your yes.

To the workshop