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

removed std::endl calls which were causing significant slowdown when writing #62

Merged
merged 1 commit into from
Jul 2, 2022

Conversation

TAImatem
Copy link
Contributor

Each std::endl call causes std::flush call on top of writing end-of-line symbols.
Given amount of lines that is written on medium to large projects, that would cause significant writing slowdown and possibly excessive hard drive write calls

@TAImatem
Copy link
Contributor Author

BTW, flush and close are called at the end of dxfRW::write function anyway, so those endl calls were mostly pointless anyway

@rvt
Copy link
Member

rvt commented Jun 16, 2022

BTW, flush and close are called at the end of dxfRW::write function anyway, so those endl calls were mostly pointless anyway

I guess because it's the DXF writer it wouldn't matter a lot..

@TAImatem
Copy link
Contributor Author

I'm looking at hefty ~1.5mil lines dxf project right now. replacing endl with '\n' turns 4s write time into just 0.8s (both on Release MSVC 2019)

@TAImatem
Copy link
Contributor Author

the speed improvement would also be useful in case of batch conversions

@lordofbikes
Copy link
Member

I just wonder if you can give some more details about your testing environment.
LibreCAD, LibreCAD_3 or something different? I assume Windows, when MSVC 2019 was involved.

This was topic on the LibreCAD forum a while ago, in relation with slow network writes.
See LibreCAD/LibreCAD#1205, the forum thread is linked there.
The replacement of std::endl with "\n" was tested there too and last statement was, that there was no significant difference.
Seems I have to give it a try myself.

@TAImatem
Copy link
Contributor Author

TAImatem commented Jun 20, 2022

Basically a program that does some calculations and transformations on engineering data that was exported in DXF form and saves copy of initial DXF with added data to a separate file. Loosely based on dwg2dxf (I guess you can use just that for testing). Branch is master.
File size is at 10MiB. Platform is Windows. Hard drive is speedy NVMe SSD. I suspect that the speed difference should also be noticeable on HDDs or SATA SSDs, given the difference in write time I was able to measure.
I suppose behavior can be different on Linux, but I don't want to install Linux along with all required packages just for testing libdxfrw performance, while results on VM or WSL are probably going to be skewed

@lordofbikes lordofbikes merged commit a610710 into LibreCAD:master Jul 2, 2022
@lordofbikes
Copy link
Member

many thanks 👍

After testing on bare metal Windows and Linux I can confirm an improvement of around 4 times faster.

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