diff options
author | davidovski <david@davidovski.xyz> | 2023-12-27 22:09:27 +0000 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2023-12-27 22:09:27 +0000 |
commit | 17dbc958104165cc0ed8acfd55137065f4fdb816 (patch) | |
tree | 6579182cfa3d995338a9d5f0fbdf131eccd30fd2 /typr.sh | |
parent | a35613e0558af8dd0b6fa158272f78005946eba2 (diff) |
track performance of frames
Diffstat (limited to 'typr.sh')
-rwxr-xr-x | typr.sh | 36 |
1 files changed, 25 insertions, 11 deletions
@@ -44,18 +44,24 @@ typr_draw_text () { e="$entered_text" lt="" while [ "$t" ] ; do - lt=$ct - ct=${t%${t#?}} - ce=${e%${e#?}} + lt="$ct" + ct="${t%${t#?}}" t="${t#?}" - e="${e#?}" - - [ "$ct" != "$ce" ] \ - && newcolor="[0;31m" \ - || newcolor="[0;32m" + ce="${e%${e#?}}" + e="${e#?}" - [ ! "$ce" ] && newcolor="[0;37m" \ + case "$ce" in + "$ct") + newcolor="[0;32m" + ;; + "") + newcolor="[0;37m" + ;; + *) + newcolor="[0;31m" + ;; + esac [ "$lt" = " " ] && { next_word=${t%% *} @@ -73,10 +79,10 @@ typr_draw_text () { } - [ "$color" = "[0;31m" ] &&{ + [ "$color" = "[0;31m" ] && { [ "$ce" = " " ] && draw="${draw}_" || draw="${draw}$ce" } || { - draw="$draw$ct" + draw="$draw$ct" } i=$((i+1)) @@ -171,9 +177,17 @@ typr_main () { correct_kp=0 export correct_kp total_kp + fstart=$(date +%s%N) while true; do typr_draw_text + + # calculate performance + fend=$(date +%s%N) + msperframe=$(((fend-fstart)/1000000)) + printf "[0;0H%6s" "$msperframe" + c="$(tty_readc)" + fstart=$(date +%s%N) case "$c" in ''|'') break;; '') |