- How can we measure the performance of a small fragment of code?
Micro-benchmarks can measure the performance of small fragments of code in isolation. To measure the performance of the same fragment in the context of a program, we have to use a profiler.
- Why are small and frequent memory allocations particularly bad for performance?
Processing small amounts of data usually involves a correspondingly small amount of computing and is therefore very fast. Memory allocation adds a constant overhead, not proportional to the data size. The relative impact is larger when the processing time is short. In addition, memory allocation may use a global lock or otherwise serialize multiple threads.
- What is local buffer optimization and how does it work?
Local buffer optimization replaces external memory allocation with a buffer that is a part of the object itself. This avoids...