Last active
July 7, 2017 16:43
-
-
Save larytet/10ceddea609d2da17aa09558ed0e04bc to your computer and use it in GitHub Desktop.
Tight echo loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function echo_loop() | |
{ | |
file=echo_file_`date +%s%N` | |
echo $file | |
echo > $file | |
counter=1 | |
end=$((SECONDS+10)) | |
while [ $SECONDS -lt $end ]; do | |
echo $counter >>$file | |
counter=$((counter+1)) | |
done | |
tail -n 1 $file | |
rm -f $file | |
} | |
CPUS=`grep -c ^processor /proc/cpuinfo` | |
pids="" | |
counter=0 | |
while [ $counter -lt $CPUS ]; do | |
echo_loop & | |
pids="$pids $!" | |
counter=$(($counter+1)) | |
done | |
wait $pids |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment