We will analyse such code
struct TalkingObject { /*...*/ };
void foo() { throw std::runtime_error("Error"); }
void bar() {
try {
TalkingObject inside;
foo();
} catch(std::logic_error const&) {
std::cout << "std::logic_error" << '\n';
}
}
int main() {
TalkingObject outside;
bar();
}
int a {5};
auto add5 = [=](int x) { return x + a; };
// auto add5 = [](int x) { return x + a; }; // error: a is not defined
int counter {};
auto inc = [&counter] { counter++; };
int even_count = 0;
for_each(v.begin(), v.end(), [&even_count] (int n) {
cout << n;
if (n % 2 == 0)
++even_count;
});
cout << "There are " << even_count
<< " even numbers in the vector." << endl;
Your abilities after Performance optimisations training
- know computational complexity issues
- know the complexity of STL containers operations
- know which features have performance penalty
- know which features can be safely used for code optimization
- know how does cache memory work and how to utilize it for faster code execution
- can use Google Benchmark to compare the performance of different pieces of code
- can use Small Object Optimisation idiom
Agenda: Day 1
- features to avoid: std::shared_ptr, std::function, exceptions, dynamic polymorphism, RTTI, dynamic allocation
- safe features: static_assert, auto, using aliases, move semantics, noexcept, constexpr, lambda, type_traits, unique_ptr, variadic templates
- constexpr
- noexcept
- recap
Agenda: Day 2
- cache memory + cachegrind
- low level optimizations: data layout in memory, cache locality, memory traversing, false sharing, integer arithmetics
- the computational complexity of algorithms and container operations
- copy elision, RVO (return value optimisation)
- Small Object Optimisation (SSO)
- string_view
- benchmarking
- recap
Activities
- pre-work to be done before our training
- pre-test pre-test at the beginning
- exercises followed by trainers implementation
- coding dojo
- participants solutions code review
- post-work with code review
- post-test one week after the training
- certificate of completion
Duration
- 2 day (12 hours with breaks)
Form
- online
- classroom
Order Performance optimisations training
Related trainings
Move semantics
One of possible optimisation techniques. It is moved out to a separate session
STL in C++17
Full review of STL containers and complexity of their operations, review of STL algorithms