Home / Forums / C++20 std::format vs snprintf & std::stringstream Benchmarks [Discussion #8]

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Tutorial

C++20 std::format vs snprintf & std::stringstream Benchmarks [Discussion #8]

ImGuiCustomizer
Custom Controls
MEMBER
Rep: 96
Join Date: Mar 2022
Posts: 6
Thanks: 95
4y ago · Mar 16, 2022 10:42 AM
#1
C++20 std::format combines the type-safety of std::stringstream with the performance of snprintf without needing manual buffer sizing.
ImGuiCustomizer · Custom Controls
Creating tabs, toggle switches, and responsive layouts in De...
The following users thanked ImGuiCustomizer for this post:
RenderLoop
Graphics Pipeline Dev
MEMBER
Rep: 348
Join Date: Jul 2020
Posts: 6
Thanks: 94
4y ago · Mar 16, 2022 12:52 PM
#2
std::format is significantly faster than iostreams because it does not allocate locale objects or virtual call overhead on every stream insertion.
RenderLoop · Graphics Pipeline Dev
Double buffering, triple buffering, vertical sync, and frame...
CodeRefactorer
Software Architect
MEMBER
Rep: 296
Join Date: Feb 2021
Posts: 6
Thanks: 21
4y ago · Mar 16, 2022 1:52 PM
#3
In C++23, std::print also outputs directly to terminal stdout with UTF-8 support without formatting into an intermediate string first!
CodeRefactorer · Software Architect
Clean architecture, SOLID principles, and refactoring legacy...