X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Fversus-external-pools%2Fbench.sh;h=7d7e9651469252304dec4145adcb42c858f88bd6;hb=ee4128723bbcf20ba0c2f4db1cad14c262d128c3;hp=b6c339f84a1f3b408aaa4b30349b3f745cf26acf;hpb=74750c7f0a8b83b3a579f4d7fc96070ca540b234;p=poolifier.git diff --git a/benchmarks/versus-external-pools/bench.sh b/benchmarks/versus-external-pools/bench.sh index b6c339f8..7d7e9651 100755 --- a/benchmarks/versus-external-pools/bench.sh +++ b/benchmarks/versus-external-pools/bench.sh @@ -1,26 +1,59 @@ -### The -t argument is needed to specify the type of task that you want to benchmark. -### Supported values are CPU_INTENSIVE +#!/usr/bin/env bash -taskType='CPU_INTENSIVE' -while getopts t: flag +usage() { + echo "Usage: $0 [-s -i -t ] [-n ]" 1>&2 + exit 1 +} + +while getopts "s:i:t:n:h" option do - case "${flag}" in - t) taskType=${OPTARG};; - esac + case "${option}" in + s) + poolSize=${OPTARG} + ;; + i) + iterations=${OPTARG} + ;; + t) + taskType=${OPTARG} + ;; + n) + taskSize=${OPTARG} + ;; + :) + echo "Error: Missing option argument for '-${OPTARG}'" >&2; + usage + ;; + \?) + # Invalid option + echo "Error: Unknown or invalid option for '-${OPTARG}'" >&2; + usage + ;; + *|h) + usage + ;; + esac done -echo 'Running bench for task type:' $taskType -export TASK_TYPE=$taskType -# Execute bench +taskType=${taskType:-'CPU_INTENSIVE'} +taskSize=${taskSize:-5000} +poolSize=${poolSize:-$(nproc --all)} +iterations=${iterations:-100000} + +echo 'Running benchmarks with pool size:' ${poolSize}', number of iterations:' ${iterations}', task type:' ${taskType} 'and task size:' ${taskSize} export NODE_ENV=production -export POOL_SIZE=10 -export NUM_ITERATIONS=100000 -hyperfine --export-markdown BENCH-100000.md --min-runs 10 \ - --prepare 'sleep 15' \ - 'node dynamic-piscina.js' \ - 'node fixed-piscina.js' \ - 'node dynamic-poolifier.js' \ - 'node fixed-poolifier.js' \ - 'node static-suchmokuo-node-worker-threads-pool.js' \ - 'node dynamic-suchmokuo-node-worker-threads-pool.js' \ - 'node threadjs.js' +export TASK_TYPE=${taskType} +export TASK_SIZE=${taskSize} +export POOL_SIZE=${poolSize} +export NUM_ITERATIONS=${iterations} +case "$OSTYPE" in + darwin*) + caffeinate ./hyperfine_benchmarks.sh + ;; + linux*) + systemd-inhibit --what=idle ./hyperfine_benchmarks.sh + ;; + *) + echo "Unsupported $OSTYPE" + ;; +esac