When we need to fill std::vector with values and the size of vector is known in advance, there are two possibilities: using emplace_back() or using operator[]. For the emplace_back() we should reserve the necessary amount of space with reserve() before emplacing into vector. This will avoid unnecessary vector regrow and benefit performance. Alternatively, if we…
All posts in C++ Performance
What are premature optimizations?
In this post we try to answer the questions “what are premature optimizations?”
Why do programs get slower with time?
We investigate why software gets slower as new features are added or data set grows and what can you do about it.
“Premature optimization is the root of all evil”. Or is it?
We investigate the topic of premature optimizations, or more specifically, in what cases you want to think early about performance.
Flexibility and Performance
In this post we talk about how to write code that is both flexible and fast!
The true price of virtual functions in C++
We talk about virtual functions, and how the performance of software with virtual functions depends on many factors: the cost of additional instructions, cache misses, branch prediction misses, instruction cache misses and compiler optimizations.
2-minute read: Class Size, Member Layout and Speed
We are exploring how class size and layout of its data members affect your program’s speed
Excessive copying in C++ and your program’s speed
We talk about C++ and its weakness for temporary objects and excessive copying. We also give some tips on how to avoid them and make your program faster.
Process polymorphic classes in lightning speed
We investigate what is the best way to store polymorphic objects in a container for fast access
The price of dynamic memory: Memory Access
If your program uses dynamic memory, its speed will depend on allocation time but also on memory access time. Here we investigate how memory access time depends on the memory layout of your data structure. We also investigate ways to speed up your program by laying out your data structure optimally.