perf expr: Allow exponents on floating point values
Ian Rogers
reviewerPATCH 1/1 perf expr: Allow exponents on floating point values
Pass the optional exponent component through to strtod that already supports it. We already have exponents in ScaleUnit and so this adds uniformity.
--- tools/perf/tests/expr.c | 2 ++ tools/perf/util/expr.l | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
tools/perf/tests/expr.c +2 -0
@@ -97,6 +97,8 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_u ret |=test (ctx,"2.2 > 2.2" ,0 ); ret |=test (ctx,"2.2 < 1.1" ,0 ); ret |=test (ctx,"1.1 > 2.2" ,0 ); + ret |=test (ctx,"1.1e10 < 1.1e100" ,1 ); + ret |=test (ctx,"1.1e2 > 1.1e-2" ,1 );if (ret) {expr__ctx_free (ctx);
tools/perf/util/expr.l +1 -1
@@ -91,7 +91,7 @@ static int literal(yyscan_t scanner) } %} -number ([0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+) +number ([0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)(e-?[0-9]+)? sch [-,=] spec \\{sch}
Signature · 1 line
2.36.1.124.g0e6072fb45-goog
Ian Rogers
reviewerQuoted 7 lines · Ian Rogers
Pass the optional exponent component through to strtod that already supports it. We already have exponents in ScaleUnit and so this adds uniformity.
Reported-by Zhengjun Xing <[email protected]>Signed-off-by Ian Rogers <[email protected]>
Ping. Simple fix with tests, PTAL. Thanks,
Ian
Quoted 34 lines
--- tools/perf/tests/expr.c | 2 ++ tools/perf/util/expr.l | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)tools/perf/tests/expr.c +2
-0@@ -97,6 +97,8 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_u ret |=test (ctx,"2.2 > 2.2" ,0 ); ret |=test (ctx,"2.2 < 1.1" ,0 ); ret |=test (ctx,"1.1 > 2.2" ,0 ); + ret |=test (ctx,"1.1e10 < 1.1e100" ,1 ); + ret |=test (ctx,"1.1e2 > 1.1e-2" ,1 );if (ret) {expr__ctx_free (ctx);tools/perf/util/expr.l +1
-2@@ -91,7 +91,7 @@ static int literal(yyscan_t scanner) } %} -number ([0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+) +number ([0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)(e-?[0-9]+)? sch [-,=] spec \\{sch} --2.36.1.124.g0e6072fb45-goog
Patch looks fine to me
Quoted 37 lines · Ian Rogers
Pass the optional exponent component through to strtod that already supports it. We already have exponents in ScaleUnit and so this adds uniformity.
Reported-by Zhengjun Xing <[email protected]>Signed-off-by Ian Rogers <[email protected]>--- tools/perf/tests/expr.c | 2 ++ tools/perf/util/expr.l | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)tools/perf/tests/expr.c +2
-0@@ -97,6 +97,8 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_u ret |=test (ctx,"2.2 > 2.2" ,0 ); ret |=test (ctx,"2.2 < 1.1" ,0 ); ret |=test (ctx,"1.1 > 2.2" ,0 ); + ret |=test (ctx,"1.1e10 < 1.1e100" ,1 ); + ret |=test (ctx,"1.1e2 > 1.1e-2" ,1 );if (ret) {expr__ctx_free (ctx);tools/perf/util/expr.l +1
-1@@ -91,7 +91,7 @@ static int literal(yyscan_t scanner) } %} -number ([0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+) +number ([0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)(e-?[0-9]+)? sch [-,=] spec \\{sch}
A message that is not in the archive (sent off-list or not yet received): CAP-5=fVY-tdEzXi8fcPGQdQf+F93OTzA7z6UksQy=c6Vh7uPpA@mail.gmail.com
Arnaldo Carvalho de Melo
maintainerEm Wed, Jun 15, 2022 at 10:16:32PM -0700, Ian Rogers escreveu:
Quoted 8 lines · kajoljain
Quoted 5 lines
Patch looks fine to me
Reviewed-by Kajol Jain<[email protected]>Thanks! Arnaldo, can this one go in?
Sure, applied.
- Arnaldo
Quoted 44 lines
Ian
Quoted 41 lines · Ian Rogers
tools/perf/tests/expr.c static int test__expr(struct test_suite *t
Quoted 16 lines
Pass the optional exponent component through to strtod that already supports it. We already have exponents in ScaleUnit and so this adds uniformity.
Reported-by Zhengjun Xing <[email protected]>Signed-off-by Ian Rogers <[email protected]>--- tools/perf/tests/expr.c | 2 ++ tools/perf/util/expr.l | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)tools/perf/tests/expr.c +0
-0@@ -97,6 +97,8 @@ static int test__expr(struct test_suite *t
__maybe_unused, int subtest__maybe_uQuoted 21 lines
tools/perf/tests/expr.c +2
-0ret |=test (ctx,"2.2 > 2.2" ,0 ); ret |=test (ctx,"2.2 < 1.1" ,0 ); ret |=test (ctx,"1.1 > 2.2" ,0 ); + ret |=test (ctx,"1.1e10 < 1.1e100" ,1 ); + ret |=test (ctx,"1.1e2 > 1.1e-2" ,1 );if (ret) {expr__ctx_free (ctx);tools/perf/util/expr.l +1
-1@@ -91,7 +91,7 @@ static int literal(yyscan_t scanner) } %} -number ([0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+) +number ([0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)(e-?[0-9]+)? sch [-,=] spec \\{sch}
Signature · 1 line
- Arnaldo