Throwing Tools at C++ Ranges
summary
Compares three implementations (manual C style, C++17 algorithms, C++23 ranges via range-v3) using Google Benchmark, Cachegrind and the Visual Studio CPU profiler on WSL/Windows; measures runtime, instruction/data refs, cache misses and branch stats. Finds an initial C++23 version ~10x slower because a Cartesian product evaluated twice across lazy views; fixing by materializing the product (materialize with ranges::to vector) removes duplicated work and makes C++23 as fast or faster than C style. Also shows simple loop fusion to remove temporaries improves cache behavior and runtime.
AI-written summary · about
chapters (12)
- 0:00Performance analysis with C++ ranges
- 2:17Profiling tools setup
- 4:50Analyzing example code
- 8:43C++17 vs C-style comparison
- 19:59Cachegrind for cache efficiency
- 30:47Live demo with VS Profiler
- 35:23Optimizing C-style version
- 39:19Optimizing C++17 with accumulate
- 40:48Debug profiling with Range V3
- 45:30Fixing double evaluation
- 47:19Post-optimization re-evaluation
- 51:13Final performance comparison
related talks
01h 15mHow to Rangify Your Code
01h 04mHow to Rangify Your Code
01h 01mFrom STL to Ranges: Using Ranges Effectively
57mRange Algorithms, Views and Actions: A Comprehensive Guide
01h 34mAn Overview of Standard Ranges
01h 02mC++20 Ranges in Practice
01h 06mC++20 Ranges in Practice
01h 01mAn Overview of Standard Ranges
