Skip to content
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::endl is expensive #1367

Open
eschnett opened this issue Feb 24, 2025 · 4 comments
Open

std::endl is expensive #1367

eschnett opened this issue Feb 24, 2025 · 4 comments

Comments

@eschnett
Copy link

Using std::endl to terminate a line is expensive. See e.g. https://en.cppreference.com/w/cpp/io/manip/endl. std::endl flushes the stream, and this can be quite expensive, especially when the output is redirected to a file on a shared file system.

@JustinPrivitera
Copy link
Member

Is there a particular place where we're using std::endl to terminate a line that you have in mind? Or are you opening this ticket so that we look at all instances across Conduit?

@eschnett
Copy link
Author

I looked at the code, and it seems that conduit is using std::endl instead of \n everywhere. I don't think that's a good programming guideline. It might be worthwhile changing all std::endl to \n, and adding explicit calls to std::flush where necessary (if necessary at all).

@JustinPrivitera
Copy link
Member

We can investigate this for a future release.

@cyrush
Copy link
Member

cyrush commented Feb 26, 2025

Yes, the flush included in std::endl has a price. We can revisit -- we also have fmt that can help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants