ggerganov / imtui

ImTui: Immediate Mode Text-based User Interface C++ Library
https://imtui.ggerganov.com
MIT License
2.94k stars 123 forks source link

Experiencing slow framerate #32

Closed Clement-Praxinos closed 2 years ago

Clement-Praxinos commented 2 years ago

[MSVC 15 2017 Win32], Windows 10 Command Prompt, using PDCurses I had to fiddle a bit to make it work ( tweaking small things in the CMakeLists.txt to link PDCurses properly ). Then, even in release build, the refresh is very slow in the imtui-example-ncurses0 demo executable. I experience approximately 10fps, even the Web Assembly demo is faster and more responsive. It looks like it is spending a lot of time in ImTui_ImplNcurses_NewFrame > wgetch > sleep. Disabling the std::this_thread::sleep_for did not help either. I can provide more information if needed.

Clement-Praxinos commented 2 years ago

By getting rid of the wtimeout calls in VSync::wait from imtui-ncurses in imtui-impl-ncurses.cpp, i was able to reach 60fps and have a better user experience. I don't know if it has to do with the terminal i'm using.

ggerganov commented 2 years ago

Thanks for providing this info. I just tested with my Windows VM and indeed I also get ~10 FPS with the original code. Removing the wtimeout(stdscr, 1) calls improves the performance.

I don't remember why I added these wtimeout(stdscr, 1) calls. From the wtimeout man page, this should make the read to be blocking for 1 ms, but is seems on Windows it blocks for longer?

Anyway, it seems there is no need to block at all, so I pushed a commit which removes the wtimeout(stdscr, 1) calls. Let me know how it works for you now.

ggerganov commented 2 years ago

I believe this is now resolved. Please reopen if issue persists.