From aa98061dd65b7449999ce3f48088e24df693a042 Mon Sep 17 00:00:00 2001 From: Calin Juravle Date: Mon, 20 Oct 2014 15:58:57 +0100 Subject: [PATCH] Add perf option to art tool 'art --perf' will record user space cycle information 'art --perf-report' will also report the saved data. When using perf, the temporary data directory is not deleted. Change-Id: Iadceeb3883f815cac8ed2b8a96b9b8363661d156 --- tools/art | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tools/art b/tools/art index 010307177..af96b47fa 100644 --- a/tools/art +++ b/tools/art @@ -53,6 +53,12 @@ while true; do elif [ "$1" = "--64" ]; then DALVIKVM=dalvikvm64 shift + elif [ "$1" = "--perf" ]; then + PERF="record" + shift + elif [ "$1" = "--perf-report" ]; then + PERF="report" + shift elif expr "$1" : "--" >/dev/null 2>&1; then echo "unknown option: $1" 1>&2 exit 1 @@ -68,6 +74,11 @@ ANDROID_DATA=$PWD/android-data$$ LIBDIR=$(find_libdir) LD_LIBRARY_PATH=$ANDROID_ROOT/$LIBDIR + +if [ z"$PERF" != z ]; then + invoke_with="perf record -o $ANDROID_DATA/perf.data -e cycles:u $invoke_with" +fi + mkdir -p $ANDROID_DATA/dalvik-cache/{arm,arm64,x86,x86_64} ANDROID_DATA=$ANDROID_DATA \ ANDROID_ROOT=$ANDROID_ROOT \ @@ -75,7 +86,18 @@ ANDROID_DATA=$ANDROID_DATA \ $invoke_with $ANDROID_ROOT/bin/$DALVIKVM $lib \ -XXlib:$LIBART \ -Ximage:$ANDROID_ROOT/framework/core.art \ - "$@" + -Xcompiler-option --include-debug-symbols \ + "$@" + EXIT_STATUS=$? -rm -rf $ANDROID_DATA + +if [ z"$PERF" != z ]; then + if [ z"$PERF" = zreport ]; then + perf report -i $ANDROID_DATA/perf.data + fi + echo "Perf data saved in: $ANDROID_DATA/perf.data" +else + rm -rf $ANDROID_DATA +fi + exit $EXIT_STATUS -- 2.11.0