diff options
author | Ian Rogers <irogers@google.com> | 2021-09-23 00:46:16 -0700 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2021-09-29 13:51:04 -0300 |
commit | 94886961e324d5b6bae8e206b227c6eeb0f22c2c (patch) | |
tree | 0f2b6a404a06e0f5bcadcf6bcb8643cf2bf7cd9f /tools/perf/tests | |
parent | a8e4e880834b5dc53ff6b4cfc9f4268e61399976 (diff) | |
download | linux-94886961e324d5b6bae8e206b227c6eeb0f22c2c.tar.gz linux-94886961e324d5b6bae8e206b227c6eeb0f22c2c.tar.bz2 linux-94886961e324d5b6bae8e206b227c6eeb0f22c2c.zip |
perf metric: Avoid events for an 'if' constant result
For a metric like:
CONST if expr else CONST
if the values of CONST are identical then expr doesn't need evaluating,
and events, in order to compute a result.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: John Garry <john.garry@huawei.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Clarke <pc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandeep Dasgupta <sdasgup@google.com>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20210923074616.674826-14-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/tests')
-rw-r--r-- | tools/perf/tests/expr.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/perf/tests/expr.c b/tools/perf/tests/expr.c index 287989321d2a..f1d8411fce12 100644 --- a/tools/perf/tests/expr.c +++ b/tools/perf/tests/expr.c @@ -143,6 +143,13 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused) smt_on() ? "EVENT1" : "EVENT2", (void **)&val_ptr)); + /* The expression is a constant 1.0 without needing to evaluate EVENT1. */ + expr__ctx_clear(ctx); + TEST_ASSERT_VAL("find ids", + expr__find_ids("1.0 if EVENT1 > 100.0 else 1.0", + NULL, ctx, 0) == 0); + TEST_ASSERT_VAL("find ids", hashmap__size(ctx->ids) == 0); + expr__ctx_free(ctx); return 0; |