Commit | Line | Data |
---|---|---|
bd0e5c4d JB |
1 | #!/usr/bin/env bash |
2 | ||
7a6a0a96 | 3 | ### The -t argument permit to specify the type of task that you want to benchmark. |
7a6a0a96 | 4 | ### Supported values are CPU_INTENSIVE, IO_INTENSIVE |
37172eb1 JB |
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 | } | |
be0676b3 | 11 | |
9f7e7a99 | 12 | taskType='CPU_INTENSIVE' |
7a6a0a96 JB |
13 | taskSize=5000 |
14 | while getopts "t:s:h" option | |
9f7e7a99 | 15 | do |
7a6a0a96 | 16 | case "${option}" in |
bd0e5c4d JB |
17 | t) |
18 | taskType=${OPTARG} | |
19 | ;; | |
7a6a0a96 JB |
20 | s) |
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 | |
7a6a0a96 JB |
38 | echo 'Running benchmarks for task type:' ${taskType} 'and task size:' ${taskSize} |
39 | export TASK_TYPE=${taskType} | |
40 | export TASK_SIZE=${taskSize} | |
9f7e7a99 | 41 | # Execute bench |
42 | export NODE_ENV=production | |
be0676b3 APA |
43 | export POOL_SIZE=10 |
44 | export NUM_ITERATIONS=100000 | |
bd0e5c4d JB |
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 |