build(deps): bump poolifier
[poolifier.git] / benchmarks / versus-external-pools / bench.sh
CommitLineData
bd0e5c4d
JB
1#!/usr/bin/env bash
2
37172eb1 3usage() {
953e92bd 4 echo "Usage: $0 [-s <pool size> -i <number of iterations> -t <CPU_INTENSIVE|IO_INTENSIVE>] [-n <number of tasks>]" 1>&2
37172eb1
JB
5 exit 1
6}
be0676b3 7
953e92bd 8while getopts "s:i:t:n:h" option
9f7e7a99 9do
7a6a0a96 10 case "${option}" in
953e92bd
JB
11 s)
12 poolSize=${OPTARG}
13 ;;
14 i)
15 iterations=${OPTARG}
16 ;;
bd0e5c4d
JB
17 t)
18 taskType=${OPTARG}
19 ;;
953e92bd 20 n)
7a6a0a96
JB
21 taskSize=${OPTARG}
22 ;;
37172eb1
JB
23 :)
24 echo "Error: Missing option argument for '-${OPTARG}'" >&2;
25 usage
26 ;;
27 \?)
28 # Invalid option
29 echo "Error: Unknown or invalid option for '-${OPTARG}'" >&2;
30 usage
31 ;;
7a6a0a96 32 *|h)
37172eb1 33 usage
7a6a0a96 34 ;;
bd0e5c4d 35 esac
9f7e7a99 36done
be0676b3 37
bc2831ae
JB
38taskType=${taskType:-'CPU_INTENSIVE'}
39taskSize=${taskSize:-5000}
02749105 40poolSize=${poolSize:-$(nproc --all)}
953e92bd 41iterations=${iterations:-100000}
bc2831ae 42
953e92bd 43echo 'Running benchmarks with pool size:' ${poolSize}', number of iterations:' ${iterations}', task type:' ${taskType} 'and task size:' ${taskSize}
953e92bd 44export NODE_ENV=production
7a6a0a96
JB
45export TASK_TYPE=${taskType}
46export TASK_SIZE=${taskSize}
953e92bd
JB
47export POOL_SIZE=${poolSize}
48export NUM_ITERATIONS=${iterations}
bd0e5c4d
JB
49case "$OSTYPE" in
50 darwin*)
51 caffeinate ./hyperfine_benchmarks.sh
52 ;;
53 linux*)
54 systemd-inhibit ./hyperfine_benchmarks.sh
55 ;;
56 *)
57 echo "Unsupported $OSTYPE"
58 ;;
59esac