aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtools/perf/tests/shell/record+zstd_comp_decomp.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/perf/tests/shell/record+zstd_comp_decomp.sh b/tools/perf/tests/shell/record+zstd_comp_decomp.sh
new file mode 100755
index 000000000000..93a26a87b1f2
--- /dev/null
+++ b/tools/perf/tests/shell/record+zstd_comp_decomp.sh
@@ -0,0 +1,35 @@
1#!/bin/sh
2# Zstd perf.data compression/decompression
3
4trace_file=$(mktemp /tmp/perf.data.XXX)
5perf_tool=perf
6output=/dev/null
7
8skip_if_no_z_record() {
9 $perf_tool record -h 2>&1 | grep '\-z, \-\-compression\-level'
10}
11
12collect_z_record() {
13 echo "Collecting compressed record file:"
14 $perf_tool record -o $trace_file -g -z -F 5000 -- \
15 dd count=500 if=/dev/random of=/dev/null > $output 2>&1
16}
17
18check_compressed_stats() {
19 echo "Checking compressed events stats:"
20 $perf_tool report -i $trace_file --header --stats | \
21 grep -E "(# compressed : Zstd,)|(COMPRESSED events:)" > $output 2>&1
22}
23
24check_compressed_output() {
25 $perf_tool inject -i $trace_file -o $trace_file.decomp &&
26 $perf_tool report -i $trace_file --stdio | head -n -3 > $trace_file.comp.output &&
27 $perf_tool report -i $trace_file.decomp --stdio | head -n -3 > $trace_file.decomp.output &&
28 diff $trace_file.comp.output $trace_file.decomp.output > $output 2>&1
29}
30
31skip_if_no_z_record || exit 2
32collect_z_record && check_compressed_stats && check_compressed_output
33err=$?
34rm -f $trace_file*
35exit $err