Apply dependencies update
[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 taskType='CPU_INTENSIVE'
13 taskSize=5000
14 while getopts "t:s:h" option
15 do
16 case "${option}" in
17 t)
18 taskType=${OPTARG}
19 ;;
20 s)
21 taskSize=${OPTARG}
22 ;;
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 ;;
32 *|h)
33 usage
34 ;;
35 esac
36 done
37
38 echo 'Running benchmarks for task type:' ${taskType} 'and task size:' ${taskSize}
39 export TASK_TYPE=${taskType}
40 export TASK_SIZE=${taskSize}
41 # Execute bench
42 export NODE_ENV=production
43 export POOL_SIZE=10
44 export NUM_ITERATIONS=100000
45 case "$OSTYPE" in
46 darwin*)
47 caffeinate ./hyperfine_benchmarks.sh
48 ;;
49 linux*)
50 systemd-inhibit ./hyperfine_benchmarks.sh
51 ;;
52 *)
53 echo "Unsupported $OSTYPE"
54 ;;
55 esac