Mar 13, 2014 19:33
#!/bin/bash
today=$(date +%Y-%m-%d.%H:%M:%S)
out_file=res_$today.txt
echo 'starting: ' $today > $out_file
#will go 1, 10, 20,..., 50
for ((b=0, c=1; c <= 50; b++, c=b*10 ))
do
START=$(date +%s)
echo 'tasks: '$c
echo 'tasks: '$c >> $out_file
for ((a=1; a <= c; a++))
do
#run the task in silent mode in background:
sleep 3 > /dev/null 2>&1 &
done
wait
END=$(date +%s)
DIFF=$(( $END - $START ))
echo "per-task avg execution time (total: $DIFF seconds):" >> $out_file
echo $( echo "scale=2;$DIFF/$c" | bc ) >> $out_file
done
echo 'finished: ' $(date +%Y-%m-%d.%H:%M:%S) >> $out_file
bash,
programming