Add a script to sync sonar properties
[poolifier.git] / benchmarks / versus-external-pools / bench.sh
index 05c156c92b27d774f56e742b19e1df7fe81e916e..f78500f773032e33411ffdf820d1e3e582cc902c 100755 (executable)
@@ -1,37 +1,32 @@
-export NODE_ENV=production
+#!/usr/bin/env bash
 
-# Execute bench
-# export POOL_SIZE=8
-# export NUM_ITERATIONS=10000
-# hyperfine --export-markdown BENCH-10000.MD --min-runs 10 \
-#   'node dynamic-poolifier.js' \
-#   'node dynamic-suchmokuo-node-worker-threads-pool.js' \
-#   'node fixed-poolifier.js' \
-#   'node static-suchmokuo-node-worker-threads-pool.js' \
-#   'node piscina.js'
+### The -t argument is needed to specify the type of task that you want to benchmark.
+### Supported values are CPU_INTENSIVE
 
-# echo "Sleeping...."
-# sleep 60
+taskType='CPU_INTENSIVE'
+while getopts t: flag
+do
+  case "${flag}" in
+    t)
+      taskType=${OPTARG}
+      ;;
+  esac
+done
 
+echo 'Running bench for task type:' $taskType
+export TASK_TYPE=$taskType
+# Execute bench
+export NODE_ENV=production
 export POOL_SIZE=10
 export NUM_ITERATIONS=100000
-hyperfine --export-markdown BENCH-100000.MD --min-runs 10 \
-  'node static-suchmokuo-node-worker-threads-pool.js' \
-  'node dynamic-poolifier.js' \
-  'node piscina.js'
-
-# export POOL_SIZE=8
-# export NUM_ITERATIONS=50000
-# hyperfine --export-markdown BENCH-50000.MD --min-runs 10 \
-#   'node dynamic-poolifier.js' \
-#   'node dynamic-suchmokuo-node-worker-threads-pool.js' \
-#   'node fixed-poolifier.js' \
-#   'node static-suchmokuo-node-worker-threads-pool.js' \
-#   'node piscina.js'
-
-# export NUM_ITERATIONS=100000
-#   hyperfine --export-markdown BENCH-50000.MD --min-runs 20 \
-#     'node dynamic-poolifier.js' \
-#     'node static-suchmokuo-node-worker-threads-pool.js' \
-#     'node piscina.js'
-
+case "$OSTYPE" in
+  darwin*)
+    caffeinate ./hyperfine_benchmarks.sh
+    ;;
+  linux*)
+    systemd-inhibit ./hyperfine_benchmarks.sh
+    ;;
+  *)
+    echo "Unsupported $OSTYPE"
+    ;;
+esac