Skip to content

Commit eed79a7

Browse files
committed
[BAEL-9370] Added script to start and profile the app
1 parent 1bc3f89 commit eed79a7

File tree

1 file changed

+62
-0
lines changed
  • persistence-modules/spring-data-jpa-repo-5/scripts

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
### Perf is needed ###
5+
# brew install gperftools
6+
7+
APP_COMMAND=""
8+
9+
case "$1" in
10+
aot)
11+
APP_COMMAND="mvn -pl spring-data-jpa-aot spring-boot:run -Dspring.aot.enabled=true -Dspring.aot.repositories.enabled=false"
12+
;;
13+
aot-repo)
14+
APP_COMMAND="mvn -pl spring-data-jpa-aot-repository spring-boot:run -Dspring.aot.enabled=true -Dspring.aot.repositories.enabled=true"
15+
;;
16+
non-aot)
17+
APP_COMMAND="java -jar spring-data-jpa-not-aot/target/spring-data-jpa-not-aot-0.0.1-SNAPSHOT.jar"
18+
;;
19+
*)
20+
echo "Error: Unknown mode '$1'. Use 'aot', 'aot-repo' or 'non-aot'."
21+
exit 1
22+
;;
23+
esac
24+
25+
# --- 1. Start your script in the background ---
26+
# Record start time in milliseconds
27+
SECONDS=0
28+
$APP_COMMAND &
29+
APP_PID=$!
30+
echo "Started APP with PID $APP_PID"
31+
32+
# --- 2. Start sampling in the background ---
33+
sudo sample $APP_PID > sample_output.txt &
34+
SAMPLE_PID=$!
35+
echo "Sampling process started (PID $SAMPLE_PID)"
36+
echo "Waiting for service at http://localhost:8080/get-user ..."
37+
38+
# --- 3. Poll the endpoint until it returns HTTP 200 ---
39+
while [ "$(curl -s -o /dev/null -L -w ''%{http_code}'' http://localhost:8080/get-user)" != 200 ]
40+
do sleep 0.001;
41+
done
42+
43+
# Capture elapsed time (SECONDS has fractional part)
44+
ELAPSED=$(printf "%.3f" "$SECONDS")
45+
46+
## --- 4. Stop sampling and show results ---
47+
#echo "Stopping sample..."
48+
#sudo kill -INT "$SAMPLE_PID"
49+
#wait "$SAMPLE_PID" 2>/dev/null || true
50+
#
51+
## Give sample a moment to flush output
52+
#sleep 2
53+
54+
# --- 5. Clean up ---
55+
echo "Stopping startup process..."
56+
kill "$APP_PID" 2>/dev/null || true
57+
58+
# Give app a moment to shutdown
59+
sleep 2
60+
61+
echo "Done."
62+
echo "Service ready after $ELAPSED seconds"

0 commit comments

Comments
 (0)