bench.sh: ensure default values are set
[poolifier.git] / benchmarks / versus-external-pools / bench.sh
1 #!/usr/bin/env bash
2
3 ### The -t argument permit to specify the type of task that you want to benchmark.
4 ### Supported values are CPU_INTENSIVE, IO_INTENSIVE
5 ### The -s argument permit to specify the size of task that you want to benchmark.
6
7 usage() {
8 echo "Usage: $0 [-t <CPU_INTENSIVE|IO_INTENSIVE>] [-s <number of tasks>]" 1>&2
9 exit 1
10 }
11
12 while getopts "t:s:h" option
13 do
14 case "${option}" in
15 t)
16 taskType=${OPTARG}
17 ;;
18 s)
19 taskSize=${OPTARG}
20 ;;
21 :)
22 echo "Error: Missing option argument for '-${OPTARG}'" >&2;
23 usage
24 ;;
25 \?)
26 # Invalid option
27 echo "Error: Unknown or invalid option for '-${OPTARG}'" >&2;
28 usage
29 ;;
30 *|h)
31 usage
32 ;;
33 esac
34 done
35
36 taskType=${taskType:-'CPU_INTENSIVE'}
37 taskSize=${taskSize:-5000}
38
39 echo 'Running benchmarks for task type:' ${taskType} 'and task size:' ${taskSize}
40 export TASK_TYPE=${taskType}
41 export TASK_SIZE=${taskSize}
42 # Execute bench
43 export NODE_ENV=production
44 export POOL_SIZE=10
45 export NUM_ITERATIONS=100000
46 case "$OSTYPE" in
47 darwin*)
48 caffeinate ./hyperfine_benchmarks.sh
49 ;;
50 linux*)
51 systemd-inhibit ./hyperfine_benchmarks.sh
52 ;;
53 *)
54 echo "Unsupported $OSTYPE"
55 ;;
56 esac