docs: update benchmark versus external pools results
[poolifier.git] / benchmarks / versus-external-pools / bench.sh
... / ...
CommitLineData
1#!/usr/bin/env bash
2
3usage() {
4 echo "Usage: $0 [-s <pool size> -i <number of iterations> -t <CPU_INTENSIVE|IO_INTENSIVE>] [-n <number of tasks>]" 1>&2
5 exit 1
6}
7
8while getopts "s:i:t:n:h" option
9do
10 case "${option}" in
11 s)
12 poolSize=${OPTARG}
13 ;;
14 i)
15 iterations=${OPTARG}
16 ;;
17 t)
18 taskType=${OPTARG}
19 ;;
20 n)
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
36done
37
38taskType=${taskType:-'CPU_INTENSIVE'}
39taskSize=${taskSize:-5000}
40poolSize=${poolSize:-$(nproc --all)}
41iterations=${iterations:-100000}
42
43echo 'Running benchmarks with pool size:' ${poolSize}', number of iterations:' ${iterations}', task type:' ${taskType} 'and task size:' ${taskSize}
44export NODE_ENV=production
45export TASK_TYPE=${taskType}
46export TASK_SIZE=${taskSize}
47export POOL_SIZE=${poolSize}
48export NUM_ITERATIONS=${iterations}
49case "$OSTYPE" in
50 darwin*)
51 caffeinate ./hyperfine_benchmarks.sh
52 ;;
53 linux*)
54 systemd-inhibit --what=idle ./hyperfine_benchmarks.sh
55 ;;
56 *)
57 echo "Unsupported $OSTYPE"
58 ;;
59esac