From 151d39d5fe50ebd85c0b49e6a2fd78f1e40ca7b0 Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 15 Jul 2024 23:18:51 +0800 Subject: [PATCH] Update results and README --- README.md | 17 +++++++++++++++-- how-many-subshells.sh | 11 +++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1087ce9..7bcbb04 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,16 @@ -# how-many-subshells +# Introduction + +How many subshells should a shell subshell if a shell could subshell? + +Ever wanted to scale up your "simple" job but have no idea how many nprocs to go with? Well now you do! Just drop your script into `./jobs/` and let it scale. + +# Warnings + +1. Some of the jobs may load your system in ways I did not plan for. Use it at your own risk. + +# How To Use + +1. Clone this repository. +1. If you have a custom job, just copy your file into the `jobs` folder. `$ cp /path/to/your-job.sh ./jobs/` +1. Run the script. `$ bash how-many-subshells.sh` -How many subshells can a shell subshell if a shell could subshell? \ No newline at end of file diff --git a/how-many-subshells.sh b/how-many-subshells.sh index 6d98d14..53aff83 100755 --- a/how-many-subshells.sh +++ b/how-many-subshells.sh @@ -26,7 +26,9 @@ do CURRENT=9998 BEFORE=9999 RESULT_FILE="$RESULTS_FOLDER/$(basename $JOB_NAME)" - printf "Result file: $(readlink -f $RESULT_FILE)\n" + #printf "Result file: $(readlink -f $RESULT_FILE)\n" + + # Keep scaling up until the runtime is slower than the previous result while [[ $(echo "$CURRENT < $BEFORE" | bc) -eq 1 ]] do BEFORE=$CURRENT @@ -40,8 +42,13 @@ do done # Display the results - awk -v nproc="$NPROC" '{print NR*nproc, $0}' $RESULTS_FOLDER/* + printf "nproc\tseconds\n" + awk \ + -v nproc="$NPROC" \ + '{print NR*nproc, "\t", $0}' \ + $RESULTS_FOLDER/* done +# Clean up rm -rf $RESULTS_FOLDER