forked from quarkusio/spring-quarkus-perf-comparison
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstress.sh
More file actions
executable file
·56 lines (43 loc) · 1.79 KB
/
stress.sh
File metadata and controls
executable file
·56 lines (43 loc) · 1.79 KB
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
#!/usr/bin/env bash
callingdir="$(pwd)"
thisdir="$(realpath $(dirname "$0"))"
# Check if jbang is installed
if ! command -v jbang >/dev/null 2>&1; then
echo "Error: jbang is not installed."
echo "Please install jbang from https://www.jbang.dev/ before running this script."
exit 1
fi
# Ensure the port is free before enabling halt-on-error
kill $(lsof -t -i:8080) &>/dev/null
# Ensure infrastructure/DB is down (sanity check)
${thisdir}/infra.sh -d
set -euo pipefail
# Start infrastructure (e.g., Database)
${thisdir}/infra.sh -s
# Resource Management Notes:
# -XX:ActiveProcessorCount doesn't strictly limit available cores, but guides thread pool sizing.
# On Quarkus/Spring (Virtual Threads), this affects the Loom ForkJoin pool and Netty loops.
# For .NET, we use DOTNET_ProcessorCount to achieve similar behavior.
if [[ "$1" != *.jar ]]; then
# .NET Environment variables to mimic Java -Xmx and -XX:ActiveProcessorCount:
# DOTNET_GCHeapHardLimit: Hard memory limit in hex (0x20000000 = 512MB)
# DOTNET_ProcessorCount: Limits the CPU cores the runtime perceives
# DOTNET_gcServer: Enables Server GC for high-throughput
export DOTNET_GCHeapHardLimit=0x20000000
export DOTNET_ProcessorCount=4
export DOTNET_gcServer=1
# Suppress logging
export Logging__LogLevel__Default=None
# Launch the .NET binary
${callingdir}/$1 &
else
# Standard Java execution with memory and CPU constraints
java -XX:ActiveProcessorCount=4 -Xms512m -Xmx512m -jar ${callingdir}/$1 &
fi
# Give the app a chance to fully start before throwing load at it
sleep 20
# Run benchmark using hyperfoil via jbang
jbang wrk@hyperfoil -t2 -c100 -d20s --timeout 1s http://localhost:8080/fruits
# Cleanup: Shut down infrastructure and kill the application process
${thisdir}/infra.sh -d
kill $(lsof -t -i:8080) &>/dev/null