-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate-jfr-files
executable file
·69 lines (62 loc) · 1.92 KB
/
generate-jfr-files
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
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
if [[ $# -ne 3 ]]; then
echo "Invalid number of arguments."
echo ""
echo "Usage: generate-jfr-files <java-runtime> <class> <output-dir>"
echo ""
echo "java-runtime - the path to a Java interpreter to be used."
echo "class - the name of the class to run. It is assumed that CLASSPATH has been properly set so that this class is reachable."
echo "output-dir - the path to the directory where the output will be stored. The script will attempt to create the directory if it does not exist."
exit 1
fi
JAVA="$1"
CLASS="$2"
OUTPUT_DIR="$3"
if [[ ! -x "$JAVA" || -d "$JAVA" ]]; then
echo "Invalid path to Java interpreter."
exit 1
fi
if [[ (-e "$OUTPUT_DIR" && (! -d "$OUTPUT_DIR" || ! -w "$OUTPUT_DIR" )) ]]; then
echo "Invalid output directory."
exit 1
elif [[ ! -e "$OUTPUT_DIR" ]] && ! mkdir -p "$OUTPUT_DIR"; then
echo "Could not create output directory."
exit 1
fi
run_param() {
PARAM="$1"
OUTPUT_SUBDIR="$OUTPUT_DIR/${PARAM%=*}"
FILENAME="$OUTPUT_SUBDIR/$PARAM.jfr"
OPTION="-XX:StartFlightRecording=filename=$FILENAME,$PARAM"
mkdir -p "$OUTPUT_SUBDIR"
if ! "$JAVA" "$OPTION" "$CLASS"; then
echo "Error running parameter \"$PARAM\"."
exit 2
fi
}
mkdir -p "$OUTPUT_DIR/default"
if ! "$JAVA" -XX:StartFlightRecording=filename="$OUTPUT_DIR/default/default.jfr" "$CLASS"; then
echo "Error running default."
exit 2
fi
run_param "delay=1s"
run_param "delay=2s"
run_param "delay=3s"
run_param "disk=false"
run_param "dumponexit=true"
run_param "duration=1s"
run_param "duration=2s"
run_param "duration=3s"
run_param "name=identifier123"
run_param "maxage=1s"
run_param "maxage=2s"
run_param "maxage=3s"
run_param "maxsize=1"
run_param "maxsize=10"
run_param "maxsize=100"
run_param "maxsize=1m"
run_param "maxsize=10m"
run_param "maxsize=100m"
run_param "maxsize=1g"
run_param "path-to-gc-roots=true"
run_param "settings=jdk11-profile.jfc"