From 17dbc958104165cc0ed8acfd55137065f4fdb816 Mon Sep 17 00:00:00 2001 From: davidovski Date: Wed, 27 Dec 2023 22:09:27 +0000 Subject: track performance of frames --- typr.sh | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'typr.sh') diff --git a/typr.sh b/typr.sh index 61f29c3..4517941 100755 --- a/typr.sh +++ b/typr.sh @@ -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="" \ - || newcolor="" + ce="${e%${e#?}}" + e="${e#?}" - [ ! "$ce" ] && newcolor="" \ + case "$ce" in + "$ct") + newcolor="" + ;; + "") + newcolor="" + ;; + *) + newcolor="" + ;; + esac [ "$lt" = " " ] && { next_word=${t%% *} @@ -73,10 +79,10 @@ typr_draw_text () { } - [ "$color" = "" ] &&{ + [ "$color" = "" ] && { [ "$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 "%6s" "$msperframe" + c="$(tty_readc)" + fstart=$(date +%s%N) case "$c" in ''|'') break;; '') -- cgit v1.2.1