diff options
author | Kenneth Myhra <kennethmyhra@gmail.com> | 2023-05-02 21:04:35 +0200 |
---|---|---|
committer | Jelle Raaijmakers <jelle@gmta.nl> | 2023-05-07 14:29:25 +0200 |
commit | 36c892ae14598f301cfc355087bed474c3823221 (patch) | |
tree | 112719a4883444091fbd0ab23c80166e1d4dadb2 /Meta | |
parent | 449911c28661a836d5ebdecef014cc4e122fd3f1 (diff) | |
download | serenity-36c892ae14598f301cfc355087bed474c3823221.zip |
Meta: Add get_number_of_processing_units() to shell_include.sh
This adds the method get_number_of_processing_units() which returns the
number of processing units the system has available.
Diffstat (limited to 'Meta')
-rw-r--r-- | Meta/shell_include.sh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Meta/shell_include.sh b/Meta/shell_include.sh index 78aa59e9e5..11da2e1999 100644 --- a/Meta/shell_include.sh +++ b/Meta/shell_include.sh @@ -57,3 +57,18 @@ FUSE2FS_PATH="$(find_executable fuse2fs)" RESIZE2FS_PATH="$(find_executable resize2fs)" E2FSCK_PATH="$(find_executable e2fsck)" MKE2FS_PATH="$(find_executable mke2fs)" + +get_number_of_processing_units() { + number_of_processing_units="nproc" + SYSTEM_NAME="$(uname -s)" + + if [ "$SYSTEM_NAME" = "OpenBSD" ]; then + number_of_processing_units="sysctl -n hw.ncpuonline" + elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then + number_of_processing_units="sysctl -n hw.ncpu" + elif [ "$SYSTEM_NAME" = "Darwin" ]; then + number_of_processing_units="sysctl -n hw.ncpu" + fi + + ($number_of_processing_units) +} |