-
Notifications
You must be signed in to change notification settings - Fork 238
Open
Description
I got code similar to this:
while (running) {
terminal.draw(this::ui);
// Non-blocking read with ~16ms timeout for ~60 FPS
int c = backend.read(16);
if (c == 'q' || c == 'Q' || c == 3) {
running = false;
}
}
using the NonBlockingReader and I was getting about 6 fps - which I initially thought was due to drawing taking time but with profiler I saw that the read operation - even with 1 ms timeout takes about 65% of the time in that loop.
I know I can explore doing this in a separate thread but feels like something must be going on making it taking that much time just checking
here is the profiler tree from jvisualvm:

this is on Mac in a ghostty terminal which for similar app in rust gets 30-34 fps, I can get 21 fps with quite sloppy java - as long as I don't check for input.
Is the only option really to go multithreaded?
Metadata
Metadata
Assignees
Labels
No labels