Fork of https://github.com/oxigraph/oxigraph.git for the purpose of NextGraph project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
oxigraph/testsuite/benches/sparql_query.rs

40 lines
1.3 KiB

use criterion::{criterion_group, criterion_main, Criterion};
use oxigraph::sparql::*;
use oxigraph_testsuite::files::read_file_to_string;
use oxigraph_testsuite::manifest::TestManifest;
criterion_group!(sparql, sparql_w3c_syntax_bench);
criterion_main!(sparql);
fn sparql_w3c_syntax_bench(c: &mut Criterion) {
let manifest_urls = vec![
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/manifest-syntax.ttl",
"http://www.w3.org/2009/sparql/docs/tests/data-sparql11/manifest-sparql11-query.ttl",
];
let queries: Vec<_> = TestManifest::new(manifest_urls)
.flat_map(|test| {
let test = test.unwrap();
if test.kind == "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#PositiveSyntaxTest"
|| test.kind
== "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#PositiveSyntaxTest11" {
if let Some(query) = test.action {
Some((read_file_to_string(&query).unwrap(), query))
} else {
None
}
} else {
None
}
})
.collect();
c.bench_function("query parser", |b| {
b.iter(|| {
for (query, base) in &queries {
Query::parse(query, Some(&base)).unwrap();
}
})
});
}