-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Considering use of stb_sprintf #1038
Comments
The current performances (as of Feb2017) are those : PERFORMANCE vs MSVC 2008 32-/64-bit (GCC is even slower than MSVC): |
I'm guessing its missing debug checks or something? Seems strange how it could be so much faster yet still handle all of the same cases. |
Try GCC 5.3, and I guess you even built code in debug mode. You must build both benchmarks in release mode (for the gcc you must use the -O2 flag, or result will be built in debug mode, therefore it will be slower). In other side are was benchmarks are showing that MinGW built apps are giving faster result than MSVC's. The case of MinGW it has own independent runtime (reason of bigger size of binaries, especially if you will use -static-libgcc and -static-libstdc++) which allows you to build app even for Windows 95 (if you will don't use unsupported functions in it), and the minimal supported Windows version is dependent of that which WinAPI functions you are using. |
In case of ImGui, the biggest stake is not the performance, but having the exact same behaviour on each platform. |
I yet have to evaluate stb_printf but knowing the RAD guys I'm sure it is super efficient. I guess we could make it optional for a start, e.g. add a imconfig.h option where the user would need to add:
If the function signature are the same we can then use add some #ifdef+#define at the top of imgui.cpp?
? |
Yes, the signatures are the same. |
… NULL buffer should return the desired length. (#1038)
I have pushed this small change: If you set I think this solves the issue described in this thread without having to bother with trying to match exact prototypes between, e.g. vsnprintf and stbsp_vsnprintf. If you have time to check it out, could you let me know if it works for you, in particular with Note that the only piece of code in dear imgui relying on passing a NULL first parameter is |
…T_FORMAT_STRING_FUNCTIONS. (#1038) Renamed IMGUI_DISABLE_MATH_FUNCTIONS to IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS.
(repost with fixed typos)
Also closing this topic as it's pretty much supported now, and there's even a helper IMGUI_USE_STB_SPRINTF that perform the wrapping automatically in imgui.h if used. |
Hello,
stb_sprintf is a good replacement for sprintf, snprintf, vsprintf, and vsnprintf.
The 2 main reasons are performances (see the benchmarks in the file), and having the exact same behaviour on every platform.
One remaining issue is the implementation of vsnprintf which doesn't return the standard value. Usually, people use vsnprintf(NULL, 0, ...) to estimate the required buffer size, and then use vsnprintf(buffer, size, ...) to convert. In the current implementation, vsnprintf(NULL, 0, ...) always returns 0 (instead of returning the number of bytes required).
For ImGui, using stb_sprintf.h would ensure having the same results on every platforms.
The text was updated successfully, but these errors were encountered: