Skip to content

match_mix benchmark seems misleading #338

@Dr-Emann

Description

@Dr-Emann

The code for the match_mix benchmark is at

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions