From: Andi Kleen <ak@linux.intel.com>
To: acme@kernel.org
Cc: linux-perf-users@vger.kernel.org, Andi Kleen <ak@linux.intel.com>
Subject: [PATCH v10 4/4] Add a test case for perf script -F +metric
Date: Tue, 13 Aug 2024 14:36:51 -0700 [thread overview]
Message-ID: <20240813213651.1057362-4-ak@linux.intel.com> (raw)
In-Reply-To: <20240813213651.1057362-1-ak@linux.intel.com>
Sample a noploop workload with cycles and instructions and check if
there is at least one metric being output by perf script.
The output is
% perf test -v 98
98: perf script tests
...
script metric test
[ perf record: Woken up 2 times to write data ]
[ perf record: Captured and wrote 0.429 MB /tmp/perf-test-script.nkvvuzMOla/perf.data (8174 samples) ]
perf-exec 853636 3967843.162782: metric: 0.15 insn per cycle
perf 853636 3967843.163210: metric: 0.87 insn per cycle
perf 853636 3967843.163226: metric: 0.84 insn per cycle
perf 853636 3967843.163240: metric: 0.88 insn per cycle
perf 853636 3967843.163276: metric: 1.06 insn per cycle
perf 853636 3967843.163387: metric: 1.09 insn per cycle
perf 853636 3967843.163578: metric: 1.17 insn per cycle
perf 853636 3967843.164412: metric: 4.53 insn per cycle
perf 853636 3967843.164623: metric: 1.18 insn per cycle
perf 853636 3967843.164817: metric: 1.25 insn per cycle
script metric test [Success]
...
%
Signed-off-by: Andi Kleen <ak@linux.intel.com>
----
v2: Avoid bashisms. Use noploop
v3: Avoid false positive in shellcheck
v4: Use :S in the test (Ian, Namhyung)
v5: Update commit message.
---
tools/perf/tests/shell/script.sh | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/tools/perf/tests/shell/script.sh b/tools/perf/tests/shell/script.sh
index c1a603653662..e69c3548583a 100755
--- a/tools/perf/tests/shell/script.sh
+++ b/tools/perf/tests/shell/script.sh
@@ -7,6 +7,7 @@ set -e
temp_dir=$(mktemp -d /tmp/perf-test-script.XXXXXXXXXX)
perfdatafile="${temp_dir}/perf.data"
+scriptoutput="${temp_dir}/script"
db_test="${temp_dir}/db_test.py"
err=0
@@ -88,8 +89,21 @@ test_parallel_perf()
echo "parallel-perf test [Success]"
}
+test_metric()
+{
+ echo "script metric test"
+ if ! perf list | grep -q cycles ; then return ; fi
+ if ! perf list | grep -q instructions ; then return ; fi
+ perf record -e '{cycles,instructions}:S' -o "${perfdatafile}" perf test -w noploop
+ perf script -i "${perfdatafile}" -F +metric > $scriptoutput
+ test "`grep -c metric $scriptoutput`" -gt 5
+ grep metric $scriptoutput | head
+ echo "script metric test [Success]"
+}
+
test_db
test_parallel_perf
+test_metric
cleanup
--
2.45.2
next prev parent reply other threads:[~2024-08-13 21:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 21:36 [PATCH v10 1/4] Create source symlink in perf object dir Andi Kleen
2024-08-13 21:36 ` [PATCH v10 2/4] perf test: Support external tests for separate objdir Andi Kleen
2024-08-13 21:36 ` [PATCH v10 3/4] perf script: Fix perf script -F +metric Andi Kleen
2024-08-13 21:36 ` Andi Kleen [this message]
2024-08-25 16:58 ` [PATCH v10 1/4] Create source symlink in perf object dir Andi Kleen
2024-08-26 14:32 ` Arnaldo Carvalho de Melo
2024-08-26 15:27 ` Ian Rogers
2024-08-26 23:34 ` Arnaldo Carvalho de Melo
2024-08-26 23:53 ` Ian Rogers
2024-09-03 23:25 ` Andi Kleen
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=20240813213651.1057362-4-ak@linux.intel.com \
--to=ak@linux.intel.com \
--cc=acme@kernel.org \
--cc=linux-perf-users@vger.kernel.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).