Browse Source

Better way to calculate threads

Jeroen De Meerleer 11 months ago
parent
commit
53a732dd29
2 changed files with 5 additions and 5 deletions
  1. 1 1
      README.MD
  2. 4 4
      music-sync.sh

+ 1 - 1
README.MD

@@ -18,7 +18,7 @@ Script to sync music from one folder to another
   -t, --temp <folder>        The temporary cache for converted files (default: /tmp/converted)
   -c, --convert <bitrate>    Convert files to a given bitrate in kbps before syncing (default: 192)
   -a, --resize-art <width>   Resize album-art before syncing (default width: 200)
-  -j, --jobs <nproc>         Number of processes to use in multi-threading (default: CPU_CORES - 2)
+  -j, --jobs <nproc>         Number of processes to use in multi-threading (default: nproc - 2)
   -v, --verbose <0-6>        Set log level (default: 2)
   -h, --help                 Display this help text
 

+ 4 - 4
music-sync.sh

@@ -13,7 +13,7 @@
 #/  -t, --temp <folder>        The temporary cache for converted files (default: /tmp/converted)
 #/  -c, --convert <bitrate>    Convert files to a given bitrate in kbps before syncing (default: 192)
 #/  -a, --resize-art <width>   Resize album-art before syncing (default width: 200)
-#/  -j, --jobs <nproc>         Number of processes to use in multi-threading (default: CPU_CORES - 2)
+#/  -j, --jobs <nproc>         Number of processes to use in multi-threading (default: nproc - 2)
 #/  -v, --verbose <0-6>        Set log level (default: 2)
 #/  -h, --help                 Display this help text
 #/ 
@@ -46,7 +46,7 @@ help=false
 temp="/tmp/converted"
 convertart=false
 coverartsize=200
-jobcount="-2"
+jobcount=$(expr $(nproc) - 2)
 multithread=false
 script_name=$(basename "${0}")
 script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
@@ -189,12 +189,12 @@ GetOptions() {
 			-j|--jobs)
 				VerboseOutput 0 "--jobs given"
 				multithread=true
-				jobcount="-2"
+				jobcount=$(expr $(nproc) - 2)
 				if [[ $2 != "" ]]; then
 					jobcount=${2}
 				fi
 				shift 2
-				VerboseOutput 1 "multithreading will use ${jobcount} threads"
+				VerboseOutput 1 "Multithreading will use ${jobcount} threads"
 				;;
 			--)
 				shift