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:
-  
clearbash command fasttput clearcommand - and 
tput cuu1expensive 
in awk script:
-  
tput cuu1not expensive 
@ system( "clear" ); @
- and 
clearbash command slowertput clearcommand 
@ "clear" | getline clear ( http://pastebin.com/afh3wfgr ) @
- and 
clearbash command fasttput clearcommand 
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