X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Fversus-external-pools%2Fbench.sh;h=e1790aea0be089406ffabe024558ca6c836dedd0;hb=8fca928868a8f73a16d5d990dda9a4480ea28ab5;hp=05c156c92b27d774f56e742b19e1df7fe81e916e;hpb=be0676b3936d75f22ce55b0f71a1fb03d008a01c;p=poolifier.git diff --git a/benchmarks/versus-external-pools/bench.sh b/benchmarks/versus-external-pools/bench.sh index 05c156c9..e1790aea 100755 --- a/benchmarks/versus-external-pools/bench.sh +++ b/benchmarks/versus-external-pools/bench.sh @@ -1,37 +1,59 @@ -export NODE_ENV=production - -# Execute bench -# export POOL_SIZE=8 -# export NUM_ITERATIONS=10000 -# hyperfine --export-markdown BENCH-10000.MD --min-runs 10 \ -# 'node dynamic-poolifier.js' \ -# 'node dynamic-suchmokuo-node-worker-threads-pool.js' \ -# 'node fixed-poolifier.js' \ -# 'node static-suchmokuo-node-worker-threads-pool.js' \ -# 'node piscina.js' +#!/usr/bin/env bash -# echo "Sleeping...." -# sleep 60 +usage() { + echo "Usage: $0 [-s -i -t ] [-n ]" 1>&2 + exit 1 +} -export POOL_SIZE=10 -export NUM_ITERATIONS=100000 -hyperfine --export-markdown BENCH-100000.MD --min-runs 10 \ - 'node static-suchmokuo-node-worker-threads-pool.js' \ - 'node dynamic-poolifier.js' \ - 'node piscina.js' +while getopts "s:i:t:n:h" option +do + 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 -# export POOL_SIZE=8 -# export NUM_ITERATIONS=50000 -# hyperfine --export-markdown BENCH-50000.MD --min-runs 10 \ -# 'node dynamic-poolifier.js' \ -# 'node dynamic-suchmokuo-node-worker-threads-pool.js' \ -# 'node fixed-poolifier.js' \ -# 'node static-suchmokuo-node-worker-threads-pool.js' \ -# 'node piscina.js' - -# export NUM_ITERATIONS=100000 -# hyperfine --export-markdown BENCH-50000.MD --min-runs 20 \ -# 'node dynamic-poolifier.js' \ -# 'node static-suchmokuo-node-worker-threads-pool.js' \ -# 'node piscina.js' +taskType=${taskType:-'CPU_INTENSIVE'} +taskSize=${taskSize:-5000} +poolSize=${poolSize:-10} +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 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 ./hyperfine_benchmarks.sh + ;; + *) + echo "Unsupported $OSTYPE" + ;; +esac