{"id":462,"date":"2011-01-25T21:39:36","date_gmt":"2011-01-25T19:39:36","guid":{"rendered":"http:\/\/www.dmelody.com\/?p=462"},"modified":"2011-01-25T21:40:53","modified_gmt":"2011-01-25T19:40:53","slug":"bash-scripting-i-think-i-earned-5-stars-well-4-5","status":"publish","type":"post","link":"https:\/\/www.dmelody.com\/?p=462","title":{"rendered":"Bash scripting &#8211; I think I earned 5 stars&#8230; Well, 4.5."},"content":{"rendered":"<p>if [ -e $compare_table_file ]; then<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo &#8220;Compare table found, comparing results&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ### TODO, create two dimensional array from report and static table&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ### Compare the tables<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 threshold=5 ### if more than 5% less than const, the test would FAIL<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 frames_tested=( `cat $report_name | grep -A 50 &#8220;Throughput and Latency results&#8221; | grep -A 30 &#8220;Frame&#8221; | grep -G &#8220;[0-9]&#8221;| grep -v &#8220;Run&#8221; | awk {&#8216;print $1&#8243; &#8220;$3&#8217;}` )<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 frames_compared_to=( `cat $compare_table_file | sed &#8216;s\/\\&#8221;\/\/&#8217; | grep -A 30 &#8220;Frame&#8221; | grep -G &#8220;[0-9]&#8221;| grep -v &#8220;Run&#8221; | awk {&#8216;print $1&#8243; &#8220;$3&#8217;}` )<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 let test_frames_tested=${#frames_tested[*]}\/2<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 let test_frames_comprated=${#frames_compared_to[*]}\/2<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if [ $test_frames_tested -eq 1 ]; then<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo &#8220;wrong count of frames and results&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 reportSuccess=&#8221;FAIL&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fi<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if [ $test_frames_comprated -eq 1 ]; then<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo &#8220;wrong count of frames and consts&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 reportSuccess=&#8221;FAIL&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fi<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ## Ugly solution to solve the bad output<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 let runtime1=${#frames_tested[*]}-1<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 let runtime2=${#frames_compared_to[*]}-1<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo -e &#8220;====\\t ==========\\t ========\\t ========&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo -e &#8220;Size\\t Throughput\\t Constant\\t Variance&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo -e &#8220;====\\t ==========\\t ========\\t ========&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #for i in `seq 0 2 ${#frames_tested[*]}`; do<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 for i in `seq 0 2 $runtime1`; do<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #for b in `seq 0 2 ${#frames_compared_to[*]}`; do<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 for b in `seq 0 2 $runtime2`; do<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if [ &#8220;${frames_tested[$i]}&#8221; == &#8220;${frames_compared_to[$b]}&#8221; ]; then<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 calc=$(echo &#8220;scale=2; -1 * (100 &#8211; (100 * ${frames_tested[$i+1]} \/ ${frames_compared_to[$b+1]}))&#8221; | bc)<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 rounded=$(echo &#8220;scale=0; -1 * (100 &#8211; (100 * ${frames_tested[$i+1]} \/ ${frames_compared_to[$b+1]}))&#8221; | bc)<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo -e &#8220;${frames_tested[$i]}\\t ${frames_tested[$i+1]}%\\t ${frames_compared_to[$b+1]}%\\t $calc%&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 abs_rounded=${rounded#-}<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if [ $abs_rounded -le $threshold ]; then<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 reportSuccess=&#8221;SUCCESS&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 else<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 reportSuccess=&#8221;FAIL&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fail=1<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fi<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fi<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 done<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 done<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if [ &#8220;$fail&#8221; == &#8220;1&#8221; ]; then<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 reportSuccess=&#8221;FAIL&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 else<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 reportSuccess=&#8221;SUCCESS&#8221;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fi<br \/>\nelse<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return<br \/>\nfi<\/p>\n","protected":false},"excerpt":{"rendered":"<p>if [ -e $compare_table_file ]; then \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo &#8220;Compare table found, comparing results&#8221; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ### TODO, create two dimensional array from report and static table&#8221; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ### Compare the tables \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 threshold=5 ### if more than 5% less than const, the test would FAIL \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 frames_tested=( `cat $report_name | grep -A 50 &#8220;Throughput and Latency [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[221,210],"tags":[],"class_list":["post-462","post","type-post","status-publish","format-standard","hentry","category-english","category-linux-stuff"],"_links":{"self":[{"href":"https:\/\/www.dmelody.com\/index.php?rest_route=\/wp\/v2\/posts\/462","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dmelody.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dmelody.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dmelody.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dmelody.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=462"}],"version-history":[{"count":2,"href":"https:\/\/www.dmelody.com\/index.php?rest_route=\/wp\/v2\/posts\/462\/revisions"}],"predecessor-version":[{"id":465,"href":"https:\/\/www.dmelody.com\/index.php?rest_route=\/wp\/v2\/posts\/462\/revisions\/465"}],"wp:attachment":[{"href":"https:\/\/www.dmelody.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dmelody.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dmelody.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}