Physics I / Integrated computational problem solving
Practice question · Multiple choice

A program spends 95% of its time in one function. You optimise everything else until it is instant. How much faster is the program?

Hints
  1. Take the original runtime as 100 units and write down what remains after the change.
  2. The part you did not touch sets a floor no amount of work elsewhere can go below.
Show the answer

A. About 5% faster: the untouched 95% still has to run

Why

100 units become 95, so the gain is about 5%. Amdahl’s law: the untouched fraction bounds the total speed-up however perfectly the rest is optimised. This is the argument for profiling before optimising: effort spent outside the hot path is capped before it starts, and intuitions about where time goes are usually wrong.

Read the lesson: Integrated computational problem solving →

Practise Integrated computational problem solving

The app has 8 more questions on this lesson, and keeps your place in the course. Physics I is free to start.

More questions on Integrated computational problem solving