-
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
<iostream>: std::cout with very low speed compared with printf #4853
Comments
Perhaps related to #3669. |
Yeah, I think it's a duplicate. @jiannanya Consider to use buffering output, |
This indeed seems related but we're not quite willing to resolve this as a duplicate yet, as this issue is talking about the absolute performance difference (which could have multiple causes), and |
I think it might have something to do with operator<<. operator<< is a user-defined operator here, so it’s actually a function, every operator<< call locks the buffer, but the printf locks the buffer only once (I dunno how it actually works, but I don’t think it has to be locked multi times) I’ve tested the example above, if we just call operator<< once, the speed of count is similar to printf |
Thanks, that sounds correct to us. We're going to close this as half by design (repeatedly calling |
Describe the bug
The default std::cout does much slower output to default console than printf,even use sync_with_stdio(false) .
Command-line test case
Expected behavior
The speed of std::cout is similar to the printf's.
STL version
My Local test result
The text was updated successfully, but these errors were encountered: