Consolidates Rust benchmarks

pull/470/head
Thomas 2 years ago committed by Thomas Tanon
parent a977adff91
commit f41c499ef3
  1. 56
      lib/benches/store.rs
  2. 4
      testsuite/Cargo.toml
  3. 35
      testsuite/benches/sparql_query.rs

@ -161,7 +161,55 @@ fn run_operation(store: &Store, operations: &[Operation]) {
}
}
criterion_group!(store, store_query_and_update, store_load);
fn sparql_parsing(c: &mut Criterion) {
let mut data = Vec::new();
read_data("explore-1000.nt.zst")
.read_to_end(&mut data)
.unwrap();
let operations = read_data("mix-exploreAndUpdate-1000.tsv.zst")
.lines()
.map(|l| {
let l = l.unwrap();
let mut parts = l.trim().split('\t');
let kind = parts.next().unwrap();
let operation = parts.next().unwrap();
match kind {
"query" => RawOperation::Query(operation.to_string()),
"update" => RawOperation::Update(operation.to_string()),
_ => panic!("Unexpected operation kind {kind}"),
}
})
.collect::<Vec<_>>();
let mut group = c.benchmark_group("sparql parsing");
group.sample_size(10);
group.throughput(Throughput::Bytes(
operations
.iter()
.map(|o| match o {
RawOperation::Query(q) => q.len(),
RawOperation::Update(u) => u.len(),
})
.sum::<usize>() as u64,
));
group.bench_function("BSBM query and update set", |b| {
b.iter(|| {
for operation in &operations {
match operation {
RawOperation::Query(q) => {
Query::parse(q, None).unwrap();
}
RawOperation::Update(u) => {
Update::parse(u, None).unwrap();
}
}
}
})
});
}
criterion_group!(store, sparql_parsing, store_query_and_update, store_load);
criterion_main!(store);
@ -183,6 +231,12 @@ fn read_data(file: &str) -> impl BufRead {
BufReader::new(zstd::Decoder::new(File::open(file).unwrap()).unwrap())
}
#[derive(Clone)]
enum RawOperation {
Query(String),
Update(String),
}
#[allow(clippy::large_enum_variant)]
#[derive(Clone)]
enum Operation {

@ -20,7 +20,3 @@ text-diff = "0.4"
[dev-dependencies]
criterion = "0.4"
[[bench]]
name = "sparql_query"
harness = false

@ -1,35 +0,0 @@
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![
"https://w3c.github.io/rdf-tests/sparql/sparql10/manifest-syntax.ttl",
"https://w3c.github.io/rdf-tests/sparql/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" {
test.action.map(|query| (read_file_to_string(&query).unwrap(), query))
} else {
None
}
})
.collect();
c.bench_function("query parser", |b| {
b.iter(|| {
for (query, base) in &queries {
Query::parse(query, Some(base)).unwrap();
}
})
});
}
Loading…
Cancel
Save