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

Test windows performances #207

Open
flagarde opened this issue Dec 12, 2022 · 10 comments
Open

Test windows performances #207

flagarde opened this issue Dec 12, 2022 · 10 comments

Comments

@flagarde
Copy link
Collaborator

@MCWertGaming You mentioned last time the Microsoft Windows terminal was quite slow.. Could you provide some code showing this ? I found some windows api to write to console... maybe it would be faster but this need some tests.

@MCWertGaming
Copy link
Collaborator

That the terminal is pretty slow compared to linux can be seen in https://github.com/MCWertGaming/Furdevs-Chess. It's a small program I did in two weeks for a game jam. The drawing performance is pretty poor - while I draw the whole frame every time, which isn't ideal but I had to less time for optimizing that.

What I personally need is a renderer which is capable of updating the screen without the flashing you'll notice in my program on windows.

@flagarde
Copy link
Collaborator Author

ok thank I will try with the windows API for terminal and see if there is improvements

@MCWertGaming
Copy link
Collaborator

MCWertGaming commented Dec 18, 2022

We can improve std::cout performance by optionally disabling the printf compatibility. I think that this plus an efficient rendering algorythm in the window class would do the trick.

@MCWertGaming
Copy link
Collaborator

I have some more time now and think that I'll make a Fork to implement #213 and look into finding a way to make real time applications / rendering usable on windows as well. I'll contribute it into cpp-terminal then when it's working ^^

@flagarde
Copy link
Collaborator Author

flagarde commented Jan 1, 2023

It seems the cout is not buffered on windows or some strange thing like this.. i found some function to turn it on but i didn't check the performance.. would be nice to have a special test for this... A very difficult screen to fill with many colors etc to have some benchmark

@flagarde
Copy link
Collaborator Author

flagarde commented Jan 1, 2023

std::cout in MSVC is slow (https://web.archive.org/web/20170329163751/https://connect.microsoft.com/VisualStudio/feedback/details/642876/std-wcout-is-ten-times-slower-than-wprintf-performance-bug-in-c-library).

"It is an unfortunate consequence of how our C and C++ Standard Library implementations are designed. The problem is that when printing to the console (instead of, say, being redirected to a file), neither our C nor C++ I/O are buffered by default. This is sometimes concealed by the fact that C I/O functions like printf() and puts() temporarily enable buffering while doing their work"

Microsoft suggests this fix (to enable buffering on cout/stdout):

setvbuf(stdout, 0, _IOLBF, 4096)

@MCWertGaming
Copy link
Collaborator

Oh, seems nice! I'll make a small animation of some sort as example for this.

@MCWertGaming
Copy link
Collaborator

I mean just rendering performance is not the only thing I need, some kind of centering of the content and resizing would be a nice addition, but I'm not yet sure how to implement something like that in a universal renderer. But having a constant rendering performance and some simple interface for interacting with a rendering buffer (the Window class) would be a nice start!

@flagarde
Copy link
Collaborator Author

flagarde commented Jan 1, 2023

@MCWertGaming Yes, it's just the start of the story but if this can improve some performance it would be great to add it.

@MCWertGaming
Copy link
Collaborator

Of course, we'll implement it

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

2 participants