Faster Complex Numbers
summary
Benchmarks compare std::complex, a naive eager class, expression-template wrappers and hand‑crafted C-style code across GCC, Clang and MSVC; std::complex generates extra library calls doing IEEE corner-case checks, causing slowdowns (Clang shows ~3× gap). Expression templates recover much of the abstraction on MSVC (about 2× speedup) and help on complex expressions, while hand‑crafted code remains fastest on some compilers; GCC with -ffast-math enabled eliminates the gap. Build and assembly inspection confirm the cause.
AI-written summary · about
chapters (15)
- 0:00Introduction to complex numbers
- 1:57Geometric representation
- 2:19Applications and C++ usage
- 7:48Implementing an oscillator
- 9:03C++14 lambdas
- 9:59Complex resonator filter
- 12:48Performance benchmarks
- 15:21Expression templates technique
- 17:22Implementing expression templates
- 22:05Assembly analysis
- 22:35IEEE 754 compliance issues
- 23:01Fast math optimization
- 26:51Final conclusions
- 28:15Q&A session
- 29:26Further discussion
related talks
01h 06m“Improving Performance Through Compiler Switches..."
05mMoving an `int` Is Slow: Debug Performance Matters!
50mC++ Costless Abstractions: the compiler view
47mReducing Template Compilation Overhead, Using C++11, 14, 17, and 20.
54mThrowing Tools at C++ Ranges
01h 03mCompute More in Less Time Using C++ Simd Wrapper Libraries
57mA Tour of Polymorphism Techniques in C++
01h 44mImproving C++ Compilation Times: Tools & Techniques
