Bash vs Dash performance on Pi - Raspberry Pi Forums


by default, debian wheezy distros use dash default shell. bash, however, continues default interactive shell. unfamiliar dash, dash thin shell without c-style commands can find in bash. dash 100k in size versus bash's 900k size. makes difference in performance while running large tasks.

ran benchmark on pi compare 2 using (note change 'bash' 'dash' testing dash)

code: select all

time bash -c 'for in $(seq 1 1000000);do [ 1 = 1 ];done'
bash test came these results:

code: select all

real	0m55.922s user	0m54.360s sys	0m1.800s 
whereas dash performed with:

code: select all

real	0m14.264s user	0m14.170s sys	0m0.140s 
source code from: http://unix.stackexchange.com/questions ... -than-bash

dash crushed bash in performance. however, relatively simple task. if add in string manipulation, array storage, output file between loops, etc. etc. number of lines have put in make dash happy continually increases. sake of time may easier use linux station/server run bash , forget our woes. don't have such luxury @ work scripts have made since pi available linux device need run 24/7. understand there workarounds , options play along now.

i'm wanting know if converting more complex script bashisms posix-compliant format run faster, on pi. since complexity of task remains same, , converting posix-compliant mean large increase of lines of code, question if performance increase. number of variables , memory required run possibly overtake advantages.

have of found converting large, complex bash scripts dash/posix-compliant shells ran faster , more efficiently on pi?



as pathetic example, it's taking python source code , converting c++ running 2 against each other. if python (bash) slower in execution c++ (dash), python can cut down development time algorithms easier design. quantity of code takes convert python c++ may slow c++ down because of bloat. if i'm going switch python c++, create bloat (despite efforts optimize code) find c++ no better in end? hardware adds equation screw it, we'll live!

identical script mentioned, should interested. runs across 2000+ devices on our network , requests information via snmp.

code: select all

#!/bin/bash # prompt if [ -n "$1" ] && [ $1 == "--help" ]; echo -e '\ncommand usage:' echo -e './walkdata.sh [community string] [list of arrays]\n'; exit 1 fi  if [ -n "$1" ] && [ $1 == "-h" ]; echo -e '\ncommand usage:' echo -e './walkdata.sh [community string] [list of arrays]\n'; exit 1 fi  if [ -z $1 ]; echo -e '\ncommand usage:' echo -e './walkdata.sh [community string] [list of arrays]\n'; exit 1 fi # set vars community="$1" list=$(cat $2) fake=$(date +"%c") date=( "$fake" )  echo "device,model,ssid,ip,rssi,time (d:h:m)" >> "stationipcheck-$date.csv"  device in $list 	echo "getting data for: $device"	  	ssid=$(snmpbulkwalk -v 2c -c $community $device".dcs.byu.edu" xirrus-mib::iapname -oqv)	  	if [ "$ssid" != "no such instance exists @ oid" ] 	then 		 		ssid=`echo $ssid | tr "\n" " "` 		ssid=( $ssid )  		model=$(snmpwalk -v 2c -c $community $device".dcs.byu.edu" xirrus-mib::arraymodel -oqv | cut -d ',' -f1) 		 		ip=$(snmpbulkwalk -v 2c -c $community $device".dcs.byu.edu" xirrus-mib::stationassociationipaddress -oqv) 		ip=`echo $ip | tr "\n" " "` 		ip=( $ip ) 		 		rssi=$(snmpbulkwalk -v 2c -c $community $device".dcs.byu.edu" xirrus-mib::stationassociationrssi -oqv) 		rssi=`echo $rssi | tr "\n" " "` 		rssi=( $rssi ) 		 		time=$(snmpbulkwalk -v 2c -c $community $device".dcs.byu.edu" xirrus-mib::stationassociationtime -oqv) 		time=`echo $time | tr "\n" " "` 		time=( $time ) 		 		for ((i=0; i<${#ssid[@]}; i++)); 		do 			ip=${ip[$i]} 			r=${rssi[$i]} 			s=${ssid[$i]} 			  			if [ "$i" == "0" ] 			then 				echo "$device,$model" >> "stationipcheck-$date.csv" 			fi 			echo ",,$s,$ip,$r,$t" >> "stationipcheck-$date.csv"  		done    	fi done 
[/size]



raspberrypi



Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support