Skip to content

Commit 6fbe1c4

Browse files
committed
Improve 'tools/run-perf-test.sh'
Always write results on stdout and save markdown file optionally. Use "Peak allocated" if binaries were built with MEM_STATS. JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
1 parent d35bc41 commit 6fbe1c4

File tree

4 files changed

+104
-29
lines changed

4 files changed

+104
-29
lines changed

tools/mem-stats-measure.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# Copyright 2016 Samsung Electronics Co., Ltd.
4+
# Copyright 2016 University of Szeged.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
JERRY=$1
19+
TEST=$2
20+
21+
MEM_PEAK=`$JERRY $TEST --mem-stats | grep "Peak allocated =" | awk '{print $4}'`
22+
23+
echo $MEM_PEAK

tools/mem_stats.sh renamed to tools/run-mem-stats-test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

33
# Copyright 2015-2016 Samsung Electronics Co., Ltd.
4+
# Copyright 2016 University of Szeged.
45
#
56
# Licensed under the Apache License, Version 2.0 (the "License");
67
# you may not use this file except in compliance with the License.

tools/run-perf-test.sh

Lines changed: 80 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

33
# Copyright 2014-2016 Samsung Electronics Co., Ltd.
4+
# Copyright 2016 University of Szeged.
45
#
56
# Licensed under the Apache License, Version 2.0 (the "License");
67
# you may not use this file except in compliance with the License.
@@ -26,9 +27,21 @@ function exit_err() {
2627
exit 1
2728
}
2829

29-
USAGE="Usage:\n sudo run.sh OLD_ENGINE NEW_ENGINE REPEATS TIMEOUT BENCH_FOLDER OUTPUT_FORMAT"
30+
# Check if the specified build supports memory statistics options
31+
function is_mem_stats_build() {
32+
[ -x "$1" ] || fail_msg "Engine '$1' is not executable"
3033

31-
if [ "$#" -ne 6 ]
34+
tmpfile=`mktemp`
35+
"$1" --mem-stats $tmpfile 2>&1 | grep -- "Ignoring memory statistics option because of '!MEM_STATS' build configuration." 2>&1 > /dev/null
36+
code=$?
37+
rm $tmpfile
38+
39+
return $code
40+
}
41+
42+
USAGE="Usage:\n tools/run-perf-test.sh OLD_ENGINE NEW_ENGINE REPEATS TIMEOUT BENCH_FOLDER [-m result-file-name.md]"
43+
44+
if [ "$#" -lt 5 ]
3245
then
3346
echo -e "${USAGE}"
3447
exit_err "Argument number mismatch..."
@@ -40,13 +53,20 @@ REPEATS="$3"
4053
TIMEOUT="$4"
4154
BENCH_FOLDER="$5"
4255
OUTPUT_FORMAT="$6"
56+
OUTPUT_FILE="$7"
4357

44-
if [ "${OUTPUT_FORMAT}" != "-m" ]
58+
if [ "$#" -gt 5 ]
4559
then
46-
if [ "${OUTPUT_FORMAT}" != "-c" ]
60+
if [ "${OUTPUT_FORMAT}" != "-m" ]
4761
then
48-
exit_err "Please, use -m or -c as output format specifier"
62+
exit_err "Please, use '-m result-file-name.md' as last arguments"
4963
fi
64+
if [ -z "${OUTPUT_FILE}" ]
65+
then
66+
exit_err "Missing md file name. Please, define the filename. Ex.: '-m result-file-name.md'"
67+
fi
68+
69+
rm -rf "${OUTPUT_FILE}"
5070
fi
5171

5272
if [ "${REPEATS}" -lt 1 ]
@@ -164,13 +184,13 @@ function run-compare()
164184
if [ "${OUTPUT_FORMAT}" == "-m" ]
165185
then
166186
WIDTH=42
167-
DIFF=$(printf "%s%s" "$DIFF" "$(printf "%$(($WIDTH - ${#DIFF}))s")")
168-
PERCENT=$(printf "%s%s" "$(printf "%$(($WIDTH - ${#PERCENT}))s")" "$PERCENT")
187+
MD_DIFF=$(printf "%s%s" "$DIFF" "$(printf "%$(($WIDTH - ${#DIFF}))s")")
188+
MD_PERCENT=$(printf "%s%s" "$(printf "%$(($WIDTH - ${#PERCENT}))s")" "$PERCENT")
169189

170-
format="\`%s\`<br>\`%s\`"
171-
else
172-
format="%20s : %19s"
190+
MD_FORMAT="\`%s\`<br>\`%s\`"
173191
fi
192+
193+
CONSOLE_FORMAT="%20s : %19s"
174194
else
175195
ext=""
176196

@@ -185,13 +205,13 @@ function run-compare()
185205
if [ "${OUTPUT_FORMAT}" == "-m" ]
186206
then
187207
WIDTH=20
188-
DIFF=$(printf "%s%s" "$DIFF" "$(printf "%$(($WIDTH - ${#DIFF}))s")")
189-
PERCENT=$(printf "%s%s" "$(printf "%$(($WIDTH - ${#PERCENT}))s")" "$PERCENT")
208+
MD_DIFF=$(printf "%s%s" "$DIFF" "$(printf "%$(($WIDTH - ${#DIFF}))s")")
209+
MD_PERCENT=$(printf "%s%s" "$(printf "%$(($WIDTH - ${#PERCENT}))s")" "$PERCENT")
190210

191-
format="\`%s\`<br>\`%s\`"
192-
else
193-
format="%14s : %8s"
211+
MD_FORMAT="\`%s\`<br>\`%s\`"
194212
fi
213+
214+
CONSOLE_FORMAT="%14s : %8s"
195215
fi
196216

197217
rel_mult=$(echo "$rel_mult" "$rel" | awk '{print $1 * $2;}')
@@ -200,10 +220,10 @@ function run-compare()
200220

201221
if [ "${OUTPUT_FORMAT}" == "-m" ]
202222
then
203-
printf "$format" "$DIFF" "$PERCENT" | sed "s/ /$FIGURE_SPACE/g"
204-
else
205-
printf "$format" "$DIFF" "$PERCENT"
223+
printf "$MD_FORMAT" "$MD_DIFF" "$MD_PERCENT" | sed "s/ /$FIGURE_SPACE/g" >> "${OUTPUT_FILE}"
206224
fi
225+
226+
printf "$CONSOLE_FORMAT" "$DIFF" "$PERCENT"
207227
}
208228

209229
function run-test()
@@ -213,13 +233,31 @@ function run-test()
213233
# print only filename
214234
if [ "${OUTPUT_FORMAT}" == "-m" ]
215235
then
216-
printf "%s | " "${TEST##*/}"
236+
printf "%s | " "${TEST##*/}" >> "${OUTPUT_FILE}"
237+
fi
238+
239+
printf "%50s | " "${TEST##*/}"
240+
241+
if [ "$IS_MEM_STAT" -ne 0 ]
242+
then
243+
run-compare "./tools/mem-stats-measure.sh" "mem" "${TEST}" 0 || return 1
217244
else
218-
printf "%50s | " "${TEST##*/}"
245+
run-compare "./tools/rss-measure.sh" "mem" "${TEST}" 0 k || return 1
246+
fi
247+
248+
if [ "${OUTPUT_FORMAT}" == "-m" ]
249+
then
250+
printf " | " >> "${OUTPUT_FILE}"
219251
fi
220-
run-compare "./tools/rss-measure.sh" "mem" "${TEST}" 0 k || return 1
252+
221253
printf " | "
222254
run-compare "./tools/perf.sh ${REPEATS}" "perf" "${TEST}" 3 s || return 1
255+
256+
if [ "${OUTPUT_FORMAT}" == "-m" ]
257+
then
258+
printf "\n" >> "${OUTPUT_FILE}"
259+
fi
260+
223261
printf "\n"
224262
}
225263

@@ -235,12 +273,25 @@ function run-suite()
235273

236274
date
237275

276+
is_mem_stats_build "${ENGINE_OLD}" || is_mem_stats_build "${ENGINE_NEW}"
277+
IS_MEM_STAT=$?
278+
238279
if [ "${OUTPUT_FORMAT}" == "-m" ]
239280
then
240-
echo "Benchmark | RSS<br>(+ is better) | Perf<br>(+ is better)"
241-
echo "---------: | --------- | ---------"
281+
if [ "$IS_MEM_STAT" -ne 0 ]
282+
then
283+
echo "Benchmark | Peak alloc.<br>(+ is better) | Perf<br>(+ is better)" >> "${OUTPUT_FILE}"
284+
else
285+
echo "Benchmark | RSS<br>(+ is better) | Perf<br>(+ is better)" >> "${OUTPUT_FILE}"
286+
fi
287+
echo "---------: | --------- | ---------" >> "${OUTPUT_FILE}"
288+
fi
289+
290+
if [ "$IS_MEM_STAT" -ne 0 ]
291+
then
292+
printf "%50s | %25s | %35s\n" "Benchmark" "Peak alloc.(+ is better)" "Perf(+ is better)"
242293
else
243-
printf "%50s | %25s | %35s\n" "Benchmark" "RSS<br>(+ is better)" "Perf<br>(+ is better)"
294+
printf "%50s | %25s | %35s\n" "Benchmark" "RSS(+ is better)" "Perf(+ is better)"
244295
fi
245296

246297
run-suite "${BENCH_FOLDER}"
@@ -288,11 +339,11 @@ if [ "${OUTPUT_FORMAT}" == "-m" ]
288339
then
289340
mem_percent_gmean_text=$(printf "RSS reduction: \`%0.3f%%\`" "$mem_percent_gmean")
290341
perf_percent_gmean_text=$(printf "Speed up: \`%0.3f%% %s\`" "$perf_percent_gmean" "$perf_percent_inaccuracy")
291-
printf "%s | %s | %s\n" "$gmean_label_text" "$mem_percent_gmean_text" "$perf_percent_gmean_text"
292-
else
293-
mem_percent_gmean_text=$(printf "RSS reduction: %0.3f%%" "$mem_percent_gmean")
294-
perf_percent_gmean_text=$(printf "Speed up: %0.3f%% %s" "$perf_percent_gmean" "$perf_percent_inaccuracy")
295-
printf "%50s | %25s | %51s\n" "$gmean_label_text" "$mem_percent_gmean_text" "$perf_percent_gmean_text"
342+
printf "%s | %s | %s\n" "$gmean_label_text" "$mem_percent_gmean_text" "$perf_percent_gmean_text" >> "${OUTPUT_FILE}"
296343
fi
297344

345+
mem_percent_gmean_text=$(printf "RSS reduction: %0.3f%%" "$mem_percent_gmean")
346+
perf_percent_gmean_text=$(printf "Speed up: %0.3f%% %s" "$perf_percent_gmean" "$perf_percent_inaccuracy")
347+
printf "%50s | %25s | %51s\n" "$gmean_label_text" "$mem_percent_gmean_text" "$perf_percent_gmean_text"
348+
298349
date

tools/sort-fails.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)