romkatv / zsh-prompt-benchmark

Measure how long it takes for your zsh prompt to render
Apache License 2.0
87 stars 2 forks source link

Feature Request: Speed measurement independence from key repeat time #2

Open robobenklein opened 5 years ago

robobenklein commented 5 years ago

Would be amazing to have some way to simulate pressing enter repeatedly instead of having to reduce the key-repeat time in the OS settings.

Perhaps this would mean running all the precmd hooks and then expanding (R)PROMPT in a loop?

romkatv commented 5 years ago

Changing key repeat manually sucks indeed. I'm using GNOME, so I run benchmarks like this:

gsettings set org.gnome.desktop.peripherals.keyboard repeat-interval 1
zsh-prompt-benchmark
gsettings set org.gnome.desktop.peripherals.keyboard repeat-interval 30

For slow prompts (5 ms or greater) I use zsh-prompt-benchmark 5 1. Just 6 seconds to run a benchmark -- not too burdensome.

You can probably figure out how to change key repeat rate on your system via command line, too.

The downside of calling precmd hooks manually is that you can miss some other hooks that are invoked when displaying prompt. For example, p9k hooks preexec. And apart from hooks there can be other differences in code path.

I would be OK with automation that programmatically injects [ENTER] keys into the shell so that it behaves exactly as if [ENTER] was pressed. Send a PR if this is something you care about. For a final judgement I would still use the physical keyboard.