Skip to content

Improved writing to files by implementing the class FastOStream #94

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

Open
wants to merge 44 commits into
base: develop
Choose a base branch
from

Conversation

akriese
Copy link

@akriese akriese commented May 19, 2020

As writing to a file takes up some time in almost all TOPP-Tools, we thought, that this could be improved by avoiding the construction and destruction of sentries, as normally there is only one thread writing output to a file. For that, we built a new class FastOStream, that references a given std::ostream and writes to it using the 'os.rdbuf()->sputn(s, n)' method. Overloads for the operator<<() are different string-like types, arithmetic types (using boost::karma for conversions), DataValue and vector.

We implemented the class in multiple files (all judged to be relevant by @cbielow) and replaced the old ostreams.

Tests / testfiles had to be changed as boost::karma's conversions are different compared to the std::ios_base's. (as discussed in #4684 and #4627)

Note that this class has undefined behaviour if accessed by multiple threads at once.

The speedup of storing files lies at up to 15%, depending on the operating system.

Anton Levin Kriese and others added 30 commits April 16, 2020 14:38
It's slower to convert non-strings to strings manually, than just handing them over to FastOStream and let it do the rest.
# Conflicts:
#	src/openms/source/ANALYSIS/OPENSWATH/OpenSwathTSVWriter.cpp
@akriese akriese changed the title Improved writing to files by implementing the class Fastostream Improved writing to files by implementing the class FastOStream May 19, 2020
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

Successfully merging this pull request may close these issues.

3 participants