Commit | Line | Data |
---|---|---|
bd0e5c4d JB |
1 | #!/usr/bin/env bash |
2 | ||
37172eb1 | 3 | usage() { |
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 | 8 | while getopts "s:i:t:n:h" option |
9f7e7a99 | 9 | do |
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 | 36 | done |
be0676b3 | 37 | |
bc2831ae JB |
38 | taskType=${taskType:-'CPU_INTENSIVE'} |
39 | taskSize=${taskSize:-5000} | |
02749105 | 40 | poolSize=${poolSize:-$(nproc --all)} |
953e92bd | 41 | iterations=${iterations:-100000} |
bc2831ae | 42 | |
953e92bd | 43 | echo 'Running benchmarks with pool size:' ${poolSize}', number of iterations:' ${iterations}', task type:' ${taskType} 'and task size:' ${taskSize} |
953e92bd | 44 | export NODE_ENV=production |
7a6a0a96 JB |
45 | export TASK_TYPE=${taskType} |
46 | export TASK_SIZE=${taskSize} | |
953e92bd JB |
47 | export POOL_SIZE=${poolSize} |
48 | export NUM_ITERATIONS=${iterations} | |
bd0e5c4d JB |
49 | case "$OSTYPE" in |
50 | darwin*) | |
51 | caffeinate ./hyperfine_benchmarks.sh | |
52 | ;; | |
53 | linux*) | |
54 | systemd-inhibit ./hyperfine_benchmarks.sh | |
55 | ;; | |
56 | *) | |
57 | echo "Unsupported $OSTYPE" | |
58 | ;; | |
59 | esac |