perf: use hyperfine-action for benchmark vs. external pools
[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)}
91a40166 41numIterations=${iterations:-100000}
bc2831ae 42
91a40166 43echo 'Running benchmarks with pool size:' ${poolSize}', number of iterations:' ${numIterations}', task type:' ${taskType} 'and task size:' ${taskSize}
953e92bd 44export NODE_ENV=production
7a6a0a96
JB
45export TASK_TYPE=${taskType}
46export TASK_SIZE=${taskSize}
953e92bd 47export POOL_SIZE=${poolSize}
91a40166 48export NUM_ITERATIONS=${numIterations}
bd0e5c4d
JB
49case "$OSTYPE" in
50 darwin*)
51 caffeinate ./hyperfine_benchmarks.sh
52 ;;
53 linux*)
27c3ac59 54 systemd-inhibit --what=idle ./hyperfine_benchmarks.sh
bd0e5c4d
JB
55 ;;
56 *)
57 echo "Unsupported $OSTYPE"
58 ;;
59esac