Initial script
This commit is contained in:
47
how-many-subshells.sh
Executable file
47
how-many-subshells.sh
Executable file
@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
NPROC=$(grep -c ^processor /proc/cpuinfo)
|
||||||
|
RESULTS_FOLDER=$(mktemp --dir)
|
||||||
|
|
||||||
|
# Checking ulimit
|
||||||
|
if [[ $(ulimit) == "unlimited" ]];then
|
||||||
|
ULIMIT_YES="no"
|
||||||
|
while [[ $ULIMIT_YES == "no" ]]
|
||||||
|
do
|
||||||
|
read -p "ulimit is unlimited. This may not go well for the system. Are you sure? (yes/no): " ULIMIT_YES
|
||||||
|
if [[ $ULIMIT_YES == "yes" ]];then
|
||||||
|
break
|
||||||
|
elif [[ $ULIMIT_YES == "no" ]];then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run the job with n number of nprocs
|
||||||
|
find ./jobs -type f -name "*.sh" | \
|
||||||
|
while read JOB_NAME
|
||||||
|
do
|
||||||
|
printf "Starting on job $JOB_NAME...\n"
|
||||||
|
SCALE=1
|
||||||
|
CURRENT=9998
|
||||||
|
BEFORE=9999
|
||||||
|
RESULT_FILE="$RESULTS_FOLDER/$(basename $JOB_NAME)"
|
||||||
|
printf "Result file: $(readlink -f $RESULT_FILE)\n"
|
||||||
|
while [[ $(echo "$CURRENT < $BEFORE" | bc) -eq 1 ]]
|
||||||
|
do
|
||||||
|
BEFORE=$CURRENT
|
||||||
|
PARALLEL=$(( $NPROC * $SCALE ))
|
||||||
|
CURRENT=$( \
|
||||||
|
/bin/time --format "%e" \
|
||||||
|
bash -c "seq 1 10000000 | xargs -P $PARALLEL bash $JOB_NAME >/dev/null 2>&1" 2>&1 | \
|
||||||
|
tee -a $RESULT_FILE \
|
||||||
|
)
|
||||||
|
(( SCALE++ ))
|
||||||
|
done
|
||||||
|
|
||||||
|
# Display the results
|
||||||
|
awk -v nproc="$NPROC" '{print NR*nproc, $0}' $RESULTS_FOLDER/*
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -rf $RESULTS_FOLDER
|
3
jobs/curl_google.sh
Executable file
3
jobs/curl_google.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
curl -q https://www.google.com
|
Reference in New Issue
Block a user