-
Notifications
You must be signed in to change notification settings - Fork 30
Description
The code for the match_mix benchmark is at
atc-router/benches/match_mix.rs
Lines 29 to 30 in dc322f6
| r#"(http.path == "hello{}" && http.version == "1.1") || {} || {} || {}"#, | |
| i, "!((a == 2) && (a == 9))", "!(a == 1)", "(a == 3 && a == 4) && !(a == 5)" |
I found the grouping in the format! call to be misleading: It looks like it should be parsed as:
(maybe true based on path) || (always true (a is never equal to both 2 and 9)) || ... || ...
which would logically simplify to
(always true)
However, in expressions, || binds more tightly than &&, and the last format argument has an &&, the expression therefore parses as:
((maybe true based on path) || (always true (a is never equal to both 2 and 9)) || ... || ...) && (!(a == 5))`
which logically simplifies to
(always true) && a != 5
Further, in the Matching benchmark:
atc-router/benches/match_mix.rs
Lines 42 to 44 in dc322f6
| ctx.add_value("http.path", Value::String("hello49999".to_string())); | |
| ctx.add_value("http.version", Value::String("1.1".to_string())); | |
| ctx.add_value("a", Value::Int(3_i64)); |
The use of hello49999 as the http.path would seem to indicate that it's trying to match the middle expression in the list, but it's actually measuring the time to match against the very first matcher, just based on a not being equal to 5