bash and awk performance with clear and cursor up command -
i'm testing bash , awk script performance clear
vs tput clear
, tput cuu1
(cursor up) commands. implemented similar scripts in bash , in awk.
bash: http://pastebin.com/0dsc0a71
awk: http://pastebin.com/waj9inrx
admitting have written them in similar way, analyze different execution times.
in bash script:
-
clear
bash command fasttput clear
command - and
tput cuu1
expensive
in awk script:
-
tput cuu1
not expensive
@ system( "clear" );
@
- and
clear
bash command slowertput clear
command
@ "clear" | getline clear
( http://pastebin.com/afh3wfgr ) @
- and
clear
bash command fasttput clear
command
so seems awk performs better tput cuu1
command bash , awk script, system()
function slower other direct recall.
@ adding cpu information @
the awk script uses less cpu bash script. bash script uses 4 times more cpu awk script. possible perform bash script?
why tput cuu1
expensive in bash script?
both awk , bash calling same external clear
, tput
utilities. suspect of difference may in exec overhead of 1 versus other , difference in way 2 scripts implemented. on system clear
outputs same sequence tput clear
, docs that's case. note clear
, tput
external utilities , not bash or awk commands.
why want this? use language that's needed other reasons. save sequence in variable @ script's startup don't have make repeated calls tput
. use clear
convenience since that's - tput
more versatile.
Comments
Post a Comment