Speedup
One cook makes sandwiches for a party. Then three friends come to help. How much faster is it now?
Swipe or tap Next for the next section
One Cook, Four Cooks
You need 40 sandwiches, and each one takes a minute to make. On your own, that's 40 minutes.
Three friends turn up and you each make 10. Everyone works at the same time, so you're done in 10 minutes. Four cooks, four times as fast.
Computer scientists call that number — "how many times faster" — the speedup:
speedup = time with one workertime with many workers
Here, 40 ÷ 10 = a speedup of 4.
Doing Things at the Same Time
Working one step after another is called sequential work. Splitting a job so several workers do parts of it at the same moment is called parallel work. Computers do this too: most phones and laptops have several "cores" — separate little processors inside the same chip — that can each work on a different part of a job at once.
Real kitchens aren't quite that simple. Before anyone starts, someone has to unpack the shopping and lay everything out (5 minutes). At the end, someone has to pack all the sandwiches into one cooler (5 minutes). Extra cooks don't make those steps any faster — it's still one person unpacking one bag.
- 1 cook:50 min (5 unpacking + 40 making + 5 packing)
- 2 cooks:30 min (5 unpacking + 20 making + 5 packing)
- 4 cooks:20 min (5 unpacking + 10 making + 5 packing)
- 8 cooks:15 min (5 unpacking + 5 making + 5 packing)
| Cooks | Total time | Speedup |
|---|---|---|
| 1 | 50 min | 1× |
| 2 | 30 min | 1.67× |
| 4 | 20 min | 2.5× |
| 8 | 15 min | 3.33× |
Four cooks now give a speedup of 50 ÷ 20 = 2.5, not 4. Doubling to eight cooks only gets you to about 3.3. The one-person steps take the same 10 minutes no matter how many cooks you add — so eventually, more help barely helps at all.
Adding workers only speeds up the parts of a job that can be shared. The parts that can't be shared set a limit on how fast the whole job can ever be.
Working It Out Like a Computer Scientist
Here's the kind of question you'll see in a computer science class. A computer has four tasks to run. None of them depend on each other:
- Task A: 40 s
- Task B: 30 s
- Task C: 20 s
- Task D: 10 s
- One processor has to run them one after another: 40 + 30 + 20 + 10 =100 seconds.
- Two processors can share them. A good split is A + D on one (50 s) and B + C on the other (50 s). Both finish at the same time: 50 seconds, a speedup of 100 ÷ 50 = 2.
- A poor split — A + B on one (70 s) and C + D on the other (30 s) — takes 70 seconds, because you have to wait for the slowest processor to finish.
With parallel work, the total time is set by whichever worker finishes last. Put another way: total time = the parts that must be done one at a time + the longest of the shared parts.
Try It With Helpers
Want to see speedup happen? The Distributed Computing page lets you split a big counting job between as many helpers as you like and time the result.
5 quick questions. Pick one answer for each — you'll see why straight away.
A job takes 60 seconds on one processor. Split across several processors, it takes 20 seconds. What is the speedup?
Speedup = time with one ÷ time with many = 60 ÷ 20 = 3. It's "how many times faster," not how many seconds were saved.
Four tasks take 40, 30, 20 and 10 seconds. They're split across two processors: one runs the 40 and 10, the other runs the 30 and 20. How long does the whole job take?
Each processor has 50 seconds of work, and they work at the same time. The job is done when the last processor finishes: 50 seconds.
Why doesn't adding more and more workers keep making a job faster forever?
The parts that can't be shared set a floor on the total time. Past a point, extra helpers barely help.
A program has a 10-second part that must run on its own, plus 40 seconds of work that can be split evenly. How long does it take with 4 processors?
The 40 seconds of shareable work becomes 10 seconds on 4 processors. Add the 10 seconds that can't be shared: 10 + 10 = 20 seconds.
Which job would gain the MOST from being split across many processors?
Each photo can be resized on its own, so the work splits cleanly. Jobs where each step depends on the last can't be shared out.