CodeTheRobot

C++ Intermediate · exercise 07

Performance & memory layout

Reserve capacity up front so a hot loop stops reallocating.

C++ Intermediate lesson 07

Guided steps

  1. 1.Reserve room for 64 samples before the loop.
  2. 2.Count how many times the data pointer moves while pushing 64 samples.
  3. 3.With a correct reserve the count is zero reallocations.

Your code

Your code is saved in this browser after every run and restored next time.