-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
[QUESTION] - Keyboard event loop is slower than old version? #21
Comments
Hi, you should remove the sleep in the main loop So try to remove the sleep and to set poll_timeout to 20ms. |
I copy the main loop also from example so there is no sleep inside. I am on mobile so probably did not see the whole picture. Any ideas? |
Oh, maybe you didn't push yet. I was looking at this main loop https://github.com/tramhao/termusic/blob/tui-realm1.0/src/app.rs. You could also try to use |
Sorry that file is not in working tree. Just left for reference. I'll try it and get back to you. |
After trying several combination, and below is best for scrolling.
Meanwhile, the cpu usage is still higher than old version. Not a big deal though. |
I tried PollStrategy::UpTo(2) and 3, and it seems jumping and not consecutive scroll. |
Cpu usage will always be higher due to a dedicated thread for input listener. In my application I also give the user the possibility to specify the tick interval in order to allow them to find the best solution. For example I have a good pc, so I prefer best performance, but if someone has a potato pc I give them the possibility to set the ticks from CLI options in order to have worse performance, but less cpu usage. Another solution could be, that since termusic is more like a background application for most of the time I guess, you could implement a sleep in your main loop to perform only when there hasn't been any incoming input event for a certain amount of time. |
It's not a very big difference so I think I'll keep it simple. Thanks for the sleep advice! |
I've just released tui-realm 1.0.1, which should reduce cpu usage in input listener. |
Thanks I tested, and it's lower than before. About 0.3% in my laptop. |
I'm using below configuration:
however, in such cases, the movement in treeview is slower than before. When I change the first value to 20, movement is ok, but cpu usage is around 0.7-1.0 %. and I haven't implement music player yet, just user interface.
In old version, I use tick rate 20ms and cpu usage is only 0.2%.
It's not a very big deal, but just asking as I don't know if my implementation is all right. Basically I copy from example.
The text was updated successfully, but these errors were encountered: