Skip to content

Commit 218ca91

Browse files
olsajiriacmel
authored andcommitted
perf tests: Add parse metric test for frontend metric
Adding new metric test for frontend metric. It's stolen from x86 pmu events. Committer testing: # perf test "Parse and process metrics" 67: Parse and process metrics : Ok # perf test -v "Parse and process metrics" # 67: Parse and process metrics : --- start --- test child forked, pid 104881 metric expr inst_retired.any / cpu_clk_unhalted.thread for IPC found event inst_retired.any found event cpu_clk_unhalted.thread adding {inst_retired.any,cpu_clk_unhalted.thread}:W metric expr idq_uops_not_delivered.core / (4 * (( ( cpu_clk_unhalted.thread / 2 ) * ( 1 + cpu_clk_unhalted.one_thread_active / cpu_clk_unhalted.ref_xclk ) ))) for Frontend_Bound_SMT found event cpu_clk_unhalted.one_thread_active found event cpu_clk_unhalted.ref_xclk found event idq_uops_not_delivered.core found event cpu_clk_unhalted.thread adding {cpu_clk_unhalted.one_thread_active,cpu_clk_unhalted.ref_xclk,idq_uops_not_delivered.core,cpu_clk_unhalted.thread}:W test child finished with 0 ---- end ---- Parse and process metrics: Ok # Had to fix it to initialize that 'struct value' array sentinel with a named initializer to fix the build with some versions of clang: tests/parse-metric.c:154:7: error: missing field 'val' initializer [-Werror,-Wmissing-field-initializers] { 0 }, Signed-off-by: Jiri Olsa <[email protected]> Acked-by: Ian Rogers <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Michael Petlan <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 0a507af commit 218ca91

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tools/perf/tests/parse-metric.c

+25
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ static struct pmu_event pme_test[] = {
1717
.metric_expr = "inst_retired.any / cpu_clk_unhalted.thread",
1818
.metric_name = "IPC",
1919
},
20+
{
21+
.metric_expr = "idq_uops_not_delivered.core / (4 * (( ( cpu_clk_unhalted.thread / 2 ) * "
22+
"( 1 + cpu_clk_unhalted.one_thread_active / cpu_clk_unhalted.ref_xclk ) )))",
23+
.metric_name = "Frontend_Bound_SMT",
24+
},
2025
};
2126

2227
static struct pmu_events_map map = {
@@ -138,8 +143,28 @@ static int test_ipc(void)
138143
return 0;
139144
}
140145

146+
static int test_frontend(void)
147+
{
148+
double ratio;
149+
struct value vals[] = {
150+
{ .event = "idq_uops_not_delivered.core", .val = 300 },
151+
{ .event = "cpu_clk_unhalted.thread", .val = 200 },
152+
{ .event = "cpu_clk_unhalted.one_thread_active", .val = 400 },
153+
{ .event = "cpu_clk_unhalted.ref_xclk", .val = 600 },
154+
{ .event = NULL, },
155+
};
156+
157+
TEST_ASSERT_VAL("failed to compute metric",
158+
compute_metric("Frontend_Bound_SMT", vals, &ratio) == 0);
159+
160+
TEST_ASSERT_VAL("Frontend_Bound_SMT failed, wrong ratio",
161+
ratio == 0.45);
162+
return 0;
163+
}
164+
141165
int test__parse_metric(struct test *test __maybe_unused, int subtest __maybe_unused)
142166
{
143167
TEST_ASSERT_VAL("IPC failed", test_ipc() == 0);
168+
TEST_ASSERT_VAL("frontend failed", test_frontend() == 0);
144169
return 0;
145170
}

0 commit comments

Comments
 (0)