https://aras-p.info/blog/2022/02/25/Curious-lack-of-sprintf-scaling
https://developer.arm.com/documentation/dui0492/i/the-c-and-c---libraries/thread-safe-c-library-functions
https://twitter.com/aras_p/status/1496489672373063682
snprintf / sprintf use global locale; which the function itself is thread-safe; thus slow and not scale(contains mutex)
take away:
- for converting int to string, use std::to_chars instead of snprintf
- {fmt} comes to the rescue (increase compile time)
- For using Double-checked_locking, be ware: use atomic with memory model, don't use simple bool/int to make it cross platform.
- don't use iostream for high-performance code
- always profiling.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.