/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
fn iteration_input(&self) -> Self::IterationInput { let query = SuggestionQuery {
providers: vec![self.provider],
keyword: self.query.to_string(),
..SuggestionQuery::default()
}; // Format the message now so it doesn't take up time in the benchmark. let should_match_message = format!("should_match for query: {:?}", query);
IterationInput {
query,
should_match_message,
}
}
fn benchmarked_code(&self, store: &Self::GlobalInput, i_input: Self::IterationInput) { let suggestions = store
.query(i_input.query)
.unwrap_or_else(|e| panic!("Error querying store: {e}"));
// Make sure matches were returned or not as expected. Otherwise the // benchmark might not be testing what it's intended to test.
assert_eq!(
!suggestions.is_empty(), self.should_match, "{}",
i_input.should_match_message,
);
}
}
pubfn all_benchmarks() -> Vec<(&'static str, QueryBenchmark)> {
vec![ // Fakespot queries, these attempt to perform prefix matches with various character // lengths. // // The query code will only do a prefix match if the total input length is > 3 chars. // Therefore, to test shorter prefixes we use 2-term queries.
( "query-fakespot-hand-s",
QueryBenchmark {
provider: SuggestionProvider::Fakespot,
query: "hand s",
should_match: true,
}
),
( "query-fakespot-hand-sa",
QueryBenchmark {
provider: SuggestionProvider::Fakespot,
query: "hand sa",
should_match: true,
}
),
( "query-fakespot-hand-san",
QueryBenchmark {
provider: SuggestionProvider::Fakespot,
query: "hand san",
should_match: true,
}
),
( "query-fakespot-sani",
QueryBenchmark {
provider: SuggestionProvider::Fakespot,
query: "sani",
should_match: true,
}
),
( "query-fakespot-sanit",
QueryBenchmark {
provider: SuggestionProvider::Fakespot,
query: "sanit",
should_match: true,
}
),
( "query-fakespot-saniti",
QueryBenchmark {
provider: SuggestionProvider::Fakespot,
query: "saniti",
should_match: false,
},
),
// weather: no matches
( "query-weather-no-match-1",
QueryBenchmark {
provider: SuggestionProvider::Weather,
query: "nomatch",
should_match: false,
},
),
( "query-weather-no-match-2",
QueryBenchmark {
provider: SuggestionProvider::Weather,
query: "no match",
should_match: false,
},
),
( "query-weather-no-match-3",
QueryBenchmark {
provider: SuggestionProvider::Weather,
query: "no match either",
should_match: false,
},
),
( "query-weather-no-match-long-1",
QueryBenchmark {
provider: SuggestionProvider::Weather,
query: "city1 city2 state1 state2 keyword1 keyword2 keyword3",
should_match: false,
},
),
( "query-weather-no-match-long-2",
QueryBenchmark {
provider: SuggestionProvider::Weather,
query: "this does not match anything especially not a weather suggestion but nevertheless it is a very long query which as previously mentioned doesn't match anything at all",
should_match: false,
},
),
( "query-weather-no-match-keyword-prefix",
QueryBenchmark {
provider: SuggestionProvider::Weather,
query: "wea",
should_match: false,
},
),
( "query-weather-no-match-city-abbr",
QueryBenchmark {
provider: SuggestionProvider::Weather,
query: "ny",
should_match: false,
},
),
( "query-weather-no-match-airport-code",
QueryBenchmark {
provider: SuggestionProvider::Weather,
query: "pdx",
should_match: false,
},
),
( "query-weather-no-match-airport-code-region",
QueryBenchmark {
provider: SuggestionProvider::Weather,
query: "pdx or",
should_match: false,
},
),
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.