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

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Tutorial

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

ParanormalDev
MelonLoader / BepInEx Dev
MEMBER
Rep: 230
Join Date: Sep 2023
Posts: 21
Thanks: 58
3y ago · Sep 25, 2022 8:24 PM
#1
C++20 std::format combines the type-safety of std::stringstream with the performance of snprintf without needing manual buffer sizing.
ParanormalDev | MelonLoader & ImGui Modding
The following users thanked ParanormalDev for this post:
CSharpNinja
Senior .NET Developer
VIP
Rep: 329
Join Date: Jan 2020
Posts: 16
Thanks: 75
3y ago · Sep 25, 2022 10:33 PM
#2
std::format is significantly faster than iostreams because it does not allocate locale objects or virtual call overhead on every stream insertion.
CSharpNinja · Senior .NET Developer
C# enthusiast, building distributed backend services and hig...
ImGuiFanatic
Graphics & ImGui
MEMBER
Rep: 159
Join Date: Aug 2021
Posts: 6
Thanks: 35
3y ago · Sep 26, 2022 1:33 AM
#3
In C++23, std::print also outputs directly to terminal stdout with UTF-8 support without formatting into an intermediate string first!
ImGuiFanatic · Graphics & ImGui
Dear ImGui is the best GUI library ever made. Change my mind...