-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbench.sh
executable file
·59 lines (55 loc) · 1.26 KB
/
bench.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
usage() {
echo "Usage: $0 [-s <pool size> -i <number of iterations> -t <CPU_INTENSIVE|IO_INTENSIVE>] [-n <number of tasks>]" 1>&2
exit 1
}
while getopts "s:i:t:n:h" option
do
case "${option}" in
s)
poolSize=${OPTARG}
;;
i)
iterations=${OPTARG}
;;
t)
taskType=${OPTARG}
;;
n)
taskSize=${OPTARG}
;;
:)
echo "Error: Missing option argument for '-${OPTARG}'" >&2;
usage
;;
\?)
# Invalid option
echo "Error: Unknown or invalid option for '-${OPTARG}'" >&2;
usage
;;
*|h)
usage
;;
esac
done
taskType=${taskType:-'CPU_INTENSIVE'}
taskSize=${taskSize:-1000}
poolSize=${poolSize:-$(nproc --all)}
numIterations=${iterations:-100000}
echo 'Running benchmarks with pool size:' ${poolSize}', number of iterations:' ${numIterations}', task type:' ${taskType} 'and task size:' ${taskSize}
export NODE_ENV=production
export TASK_TYPE=${taskType}
export TASK_SIZE=${taskSize}
export POOL_SIZE=${poolSize}
export NUM_ITERATIONS=${numIterations}
case "$OSTYPE" in
darwin*)
caffeinate ./hyperfine_benchmarks.sh
;;
linux*)
systemd-inhibit --what=idle ./hyperfine_benchmarks.sh
;;
*)
echo "Unsupported $OSTYPE"
;;
esac