-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
std::format with std::chrono poor performance #3575
Comments
Thanks for the report - this is not a known issue so we'll need to investigate. |
The chrono formatter parses the entire spec into a vector and then routes all output through an |
@StephanTLavavej As I promised from my previous PRs I did started work to see how time formatting can be optimized in Microsoft STL. Basically this is slow, because the UCRT
Of course if the output buffer size is not large enough, the function will stop and return zero, but all the allocation and conversion steps will still remain. Now, if we had all these steps run once for the whole format string, perhaps it wouldn't be that bad in terms of performance. However the C++ specification of My original idea was to sanitize the format buffer to escape characters that would crash UCRT and pass the whole thing directly to At this point I'm open to suggestions. P.S. My best bet would still be to convince the UCRT team to fixup the implementation of
|
BTW, it's possibly optimizing to simplify |
Even if we optimize |
Did you really mean that we need to call I think we can avoid For |
@frederick-vs-ja You are right, but what really happens is that |
Is this a known issue or am I doing something sub-optimal?
I'm simply calling
where
buffer
is astd::string
andtime
is of typestd::chrono::system_clock::duration
and this is about 4-5 times slower than 'rolling my own' e.g.
Not sure where this huge difference can come from. Allocations?
The text was updated successfully, but these errors were encountered: