-
Notifications
You must be signed in to change notification settings - Fork 14
/
benchmark
executable file
·139 lines (121 loc) · 3.55 KB
/
benchmark
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env bash
usage() {
echo "Usage: ${PROGRAM_NAME} command dirname"
echo "command: [m|s|p|f|c|t|i|T|I|F]"
echo " -m [profiling|benchmark], specify benchmark mode"
echo " -s hostname, host name"
echo " -p port, port number"
echo " -f output file path"
echo " -c concurrency"
echo " -t time used for each warm up iteration"
echo " -i iterations number for warm up"
echo " -T time used for each measurement iteration"
echo " -I iterations number for measurement"
echo " -F forks number"
echo "dirname: test module name"
}
config(){
echo "">./benchmark-common/src/main/resources/benchmark.properties
echo 'server.host='${SERVER}>>./benchmark-common/src/main/resources/benchmark.properties
echo 'server.port='${PORT}>>./benchmark-common/src/main/resources/benchmark.properties
}
build() {
if [[ ! -d dubbo-benchmark/dubbo-serialization-native-hessian ]] && [[ ${PROJECT_DIR} = *native-hessian* ]]; then
git clone https://github.com/dubbo/dubbo-serialization-native-hessian.git
pushd dubbo-benchmark/dubbo-serialization-native-hessian
mvn clean install
popd
fi
mvn --projects benchmark-common,dubbo-benchmark/dubbo-server-base,${PROJECT_DIR} clean package
}
java_options() {
JAVA_OPTIONS="-server -Xmx1g -Xms1g -XX:MaxDirectMemorySize=1g -XX:+UseG1GC \
-Dserver.host=${SERVER} \
-Dserver.port=${PORT} \
-Dbenchmark.output=${OUTPUT} \
-Dbenchmark.concurrency=${CONCURRENCY} \
-Dbenchmark.warm.up.time=${WARM_UP_TIME} \
-Dbenchmark.warm.up.iterations=${WARM_UP_ITERATIONS} \
-Dbenchmark.measurement.iterations=${MEASUREMENT_ITERATIONS} \
-Dbenchmark.measurement.time=${MEASUREMENT_TIME} \
-Dbenchmark.forks=${FORKS}"
if [[ "x${MODE}" = "xprofiling" ]]; then
JAVA_OPTIONS="${JAVA_OPTIONS} \
-XX:+UnlockCommercialFeatures \
-XX:+FlightRecorder \
-XX:StartFlightRecording=duration=30s,filename=${PROJECT_DIR}.jfr \
-XX:FlightRecorderOptions=stackdepth=256"
fi
}
run() {
if [[ -d "${PROJECT_DIR}/target" ]]; then
JAR=`find ${PROJECT_DIR}/target/*.jar | head -n 1`
echo
echo "RUN ${PROJECT_DIR} IN ${MODE:-benchmark} MODE"
CMD="java ${JAVA_OPTIONS} -jar ${JAR}"
echo "command is: ${CMD}"
echo
${CMD}
fi
}
PROGRAM_NAME=$0
MODE="benchmark"
SERVER="localhost"
PORT="8080"
OUTPUT=""
CONCURRENCY=32
WARM_UP_TIME=10
WARM_UP_ITERATIONS=3
MEASUREMENT_TIME=10
MEASUREMENT_ITERATIONS=3
FORKS=1
OPTIND=1
while getopts "m:s:p:f:c:t:i:T:I:F:" opt; do
case "$opt" in
m)
MODE=${OPTARG}
;;
s)
SERVER=${OPTARG}
;;
p)
PORT=${OPTARG}
;;
f)
OUTPUT=${OPTARG}
;;
c)
CONCURRENCY=${OPTARG}
;;
t)
WARM_UP_TIME=${OPTARG}
;;
i)
WARM_UP_ITERATIONS=${OPTARG}
;;
T)
MEASUREMENT_TIME=${OPTARG}
;;
I)
MEASUREMENT_ITERATIONS=${OPTARG}
;;
F)
FORKS=${OPTARG}
;;
?)
echo ${OPTARG}
usage
exit 0
;;
esac
done
shift $((OPTIND-1))
PROJECT_DIR=$1
if [[ ! -d "${PROJECT_DIR}" ]]; then
usage
exit 0
fi
config
build
java_options
run