Skip to content

Commit

Permalink
Add benches and fix sample size for io
Browse files Browse the repository at this point in the history
  • Loading branch information
phillord committed Jun 21, 2024
1 parent c81f33f commit e43441f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
9 changes: 8 additions & 1 deletion benches/io.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use criterion::{criterion_group, BenchmarkId, Criterion, Throughput};
use std::fs::File;
use std::io::BufReader;
use std::time::Duration;

fn io_read(c: &mut Criterion) {
let mut group = c.benchmark_group("io_read");
Expand All @@ -26,4 +27,10 @@ fn io_read(c: &mut Criterion) {
}
}

criterion_group!(io, io_read);
criterion_group! {
name = io;
config = Criterion::default()
.sample_size(50)
.measurement_time(Duration::from_secs(20));
targets = io_read
}
37 changes: 35 additions & 2 deletions benches/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use horned_owl::io::rdf::reader::RDFOntology;
use horned_owl::model::*;
use horned_owl::ontology::component_mapped::ComponentMappedOntology;
use horned_owl::ontology::declaration_mapped::DeclarationMappedIndex;
use horned_owl::ontology::indexed::{ForIndex, OneIndexedOntology};
use horned_owl::ontology::indexed::{
ForIndex, FourIndexedOntology, OneIndexedOntology, TwoIndexedOntology,
};
use horned_owl::ontology::iri_mapped::IRIMappedIndex;
use horned_owl::ontology::logically_equal::LogicallyEqualIndex;
use horned_owl::ontology::set::*;
Expand Down Expand Up @@ -142,7 +144,7 @@ fn set_index_tree(c: &mut Criterion) {
fn multi_index_tree(c: &mut Criterion) {
let mut group = c.benchmark_group("multi_index_tree");

for n in [100, 1_000, 10_000, 100_000].iter() {
for n in [100, 1_000, 10_000, 50_000, 100_000].iter() {
group.throughput(Throughput::Elements(*n as u64));
group.bench_with_input(BenchmarkId::new("SetOntology", n), n, |b, &n| {
b.iter(|| {
Expand Down Expand Up @@ -180,6 +182,23 @@ fn multi_index_tree(c: &mut Criterion) {
},
);

group.bench_with_input(
BenchmarkId::new("SetAndDeclarationMappedOntology", n),
n,
|b, &n| {
b.iter(|| {
let b = Build::new_rc();
// This is a more realistic use of TwoIndexOntology
let mut o: TwoIndexedOntology<_, Rc<AnnotatedComponent<_>>, _, _> =
TwoIndexedOntology::new(
SetIndex::default(),
DeclarationMappedIndex::default(),
);
create_tree(&b, &mut o, n);
})
},
);

group.bench_with_input(BenchmarkId::new("LogicallyEqualOntology", n), n, |b, &n| {
b.iter(|| {
let b = Build::new_rc();
Expand All @@ -197,6 +216,20 @@ fn multi_index_tree(c: &mut Criterion) {
create_tree(&b, &mut o, n);
})
});

group.bench_with_input(BenchmarkId::new("FourIndexedOntology", n), n, |b, &n| {
b.iter(|| {
let b = Build::new_rc();
let mut o: FourIndexedOntology<_, Rc<AnnotatedComponent<_>>, _, _, _, _> =
FourIndexedOntology::new(
SetIndex::new(),
SetIndex::new(),
SetIndex::new(),
SetIndex::new(),
);
create_tree(&b, &mut o, n);
})
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ontology/indexed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ impl<
}
}

/// FourIndexedOntology supports three indexes.
/// FourIndexedOntology supports four indexes.
#[derive(Debug)]
pub struct FourIndexedOntology<A, AA, I, J, K, L>(
TwoIndexedOntology<A, AA, I, ThreeIndexedOntology<A, AA, J, K, L>>,
Expand Down

0 comments on commit e43441f

Please sign in to comment.