petobens / trueline

Fast and extensible bash powerline prompt with true color and fancy icon support
MIT License
385 stars 36 forks source link

Improve prompt rendering upon pressing enter (i.e beyond startup) #18

Open p4vook opened 4 years ago

p4vook commented 4 years ago

Hello! Happy new year) I realized that

echo -n

benchmarking command is bad, because as seems to me, it does not render PS1. I held enter, recorded screen and saw, that rendering takes about 6 frames (look at frames 243-249), which is about 85 ms (framerate is 70 FPS). And I think, it's the reason to borrow some stuff from powerlevel10k. (the original video may be found here) recording

petobens commented 4 years ago

Yeah I tried using https://github.com/romkatv/zsh-prompt-benchmark but it's for zsh only. When I wrote trueline I tried to optimize startup time rather than this scenario described in your video. Let's leave this open then and I'll try to tackle it (no idea when though). Thanks for the report (feel free to open a PR if you get to this before I do)

p4vook commented 4 years ago

My friend told me another way of benchmarking: copy and paste this script into bash:

start=$(date +"%s.%N")

end=$(date +"%s.%N")
printf "print(($end - $start) / 100)" | python3

This is accurate. I get about 65 ms when my processor runs 4 GHz, if it's frequency is about 900 MHz (typical battery saving), I get about 175 ms.