linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Leo Yan <leo.yan@linaro.org>
Cc: Ian Rogers <irogers@google.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 2/2] perf test: Introduce script for java symbol testing
Date: Fri, 12 Aug 2022 16:47:43 -0300	[thread overview]
Message-ID: <YvauX7u69u9AeID/@kernel.org> (raw)
In-Reply-To: <20220806033434.121908-3-leo.yan@linaro.org>

Em Sat, Aug 06, 2022 at 11:34:34AM +0800, Leo Yan escreveu:
> This commit introduces a script for testing java symbols.
> 
> The test records for java program, inject samples with JIT samples, then
> check specific words "Interpreter" and "jdk.internal" in the report, the
> test will pass if these two symbols are detected.
> 
> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> ---
>  tools/perf/tests/shell/test_java_symbol.sh | 66 ++++++++++++++++++++++
>  1 file changed, 66 insertions(+)
>  create mode 100755 tools/perf/tests/shell/test_java_symbol.sh
> 
> diff --git a/tools/perf/tests/shell/test_java_symbol.sh b/tools/perf/tests/shell/test_java_symbol.sh
> new file mode 100755
> index 000000000000..45d42a9fdca5
> --- /dev/null
> +++ b/tools/perf/tests/shell/test_java_symbol.sh
> @@ -0,0 +1,66 @@
> +#!/bin/bash
> +# Test java symbol
> +
> +# SPDX-License-Identifier: GPL-2.0
> +# Leo Yan <leo.yan@linaro.org>, 2022
> +
> +PERF_DATA=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
> +PERF_INJ_DATA=$(mktemp /tmp/__perf_test.perf.data.inj.XXXXX)
> +
> +cleanup_files()
> +{
> +	echo "Cleaning up files..."
> +	rm -f ${PERF_DATA}
> +	rm -f ${PERF_INJ_DATA}
> +}
> +
> +trap cleanup_files exit term int
> +
> +if [ -e "$PWD/tools/perf/libperf-jvmti.so" ]; then
> +	LIBJVMTI=$PWD/tools/perf/libperf-jvmti.so


Will this only work if we do a:

make -C tools/perf

?

> +elif [ -e "$PWD/libperf-jvmti.so" ]; then
> +	LIBJVMTI=$PWD/libperf-jvmti.so
> +elif [ -e "$PREFIX/lib64/libperf-jvmti.so" ]; then
> +	LIBJVMTI=$PREFIX/lib64/libperf-jvmti.so
> +elif [ -e "$PREFIX/lib/libperf-jvmti.so" ]; then
> +	LIBJVMTI=$PREFIX/lib/libperf-jvmti.so
> +else
> +	echo "Fail to find libperf-jvmti.so"
> +	exit 1
> +fi
> +
> +cat <<EOF | perf record -k 1 -o $PERF_DATA jshell -s -J-agentpath:$LIBJVMTI
> +int fib(int x) {
> +	return x > 1 ? fib(x - 2) + fib(x - 1) : 1;
> +}
> +
> +int q = 0;
> +
> +for (int i = 0; i < 10; i++)
> +	q += fib(i);
> +
> +System.out.println(q);
> +EOF
> +
> +if [ $? -ne 0 ]; then
> +	echo "Fail to record for java program"
> +	exit 1
> +fi
> +
> +if ! perf inject -i $PERF_DATA -o $PERF_INJ_DATA -j; then
> +	echo "Fail to inject samples"
> +	exit 1
> +fi
> +
> +# Below is an example of the instruction samples reporting:
> +#   8.18%  jshell           jitted-50116-29.so    [.] Interpreter
> +#   0.75%  Thread-1         jitted-83602-1670.so  [.] jdk.internal.jimage.BasicImageReader.getString(int)
> +perf report --stdio -i ${PERF_INJ_DATA} 2>&1 | \
> +	egrep " +[0-9]+\.[0-9]+% .* (Interpreter|jdk\.internal).*" > /dev/null 2>&1
> +
> +if [ $? -ne 0 ]; then
> +	echo "Fail to find java symbols"
> +	exit 1
> +fi
> +
> +exit 0
> -- 
> 2.25.1

-- 

- Arnaldo

  reply	other threads:[~2022-08-12 19:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-06  3:34 [PATCH 0/2] perf test: Add test for java symbol Leo Yan
2022-08-06  3:34 ` [PATCH 1/2] perf subcmd: Set environment variable "PREFIX" Leo Yan
2022-08-06  3:34 ` [PATCH 2/2] perf test: Introduce script for java symbol testing Leo Yan
2022-08-12 19:47   ` Arnaldo Carvalho de Melo [this message]
     [not found]     ` <CAP-5=fUJxMz0C61Y1qwptc+M6rT=J3ztvguB+9bJBaQrYEQZ3w@mail.gmail.com>
2022-08-13  3:08       ` Leo Yan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YvauX7u69u9AeID/@kernel.org \
    --to=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).