Skip to content

Commit

Permalink
Fix bench marks for last
Browse files Browse the repository at this point in the history
Also add bench compile to pre-commit-config
  • Loading branch information
phillord committed Jul 2, 2024
1 parent 5025ae4 commit 00c3bdb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ repos:
entry: make pre-commit
pass_filenames: false
stages: [pre-commit, pre-push]
- id: Compile Benches
name: Running Test
language: system
entry: cargo bench --no-run
pass_filenames: false
stages: [pre-commit, pre-push]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
Expand Down
7 changes: 6 additions & 1 deletion benches/io.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use criterion::{criterion_group, AxisScale, BenchmarkId, Criterion, PlotConfiguration};
use horned_owl::model::RcStr;
use horned_owl::ontology::set::SetOntology;
use std::fs::File;
use std::io::BufReader;
use std::time::Duration;
Expand All @@ -20,7 +22,10 @@ fn io_read(c: &mut Criterion) {
b.iter(|| {
let f = File::open(format!("benches/ont/o{}.owx", n)).ok().unwrap();
let mut f = BufReader::new(f);
let _ = horned_owl::io::owx::reader::read(&mut f, Default::default()).ok();
let _: (SetOntology<RcStr>, _) =
horned_owl::io::owx::reader::read(&mut f, Default::default())
.ok()
.unwrap();
})
});
}
Expand Down
10 changes: 5 additions & 5 deletions benches/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::rc::Rc;

use criterion::{criterion_group, AxisScale, BenchmarkId, Criterion, PlotConfiguration};

use horned_owl::io::rdf::reader::RDFOntology;
use horned_owl::io::rdf::reader::ConcreteRDFOntology;
use horned_owl::model::*;
use horned_owl::ontology::component_mapped::ComponentMappedOntology;
use horned_owl::ontology::declaration_mapped::DeclarationMappedIndex;
Expand Down Expand Up @@ -237,7 +237,7 @@ fn food_to_vec() -> Vec<u8> {
std::fs::read("./benches/ont/food.owl").unwrap()
}

fn read_vec<A: ForIRI, AA: ForIndex<A>>(v: &Vec<u8>, b: Build<A>) -> RDFOntology<A, AA> {
fn read_vec<A: ForIRI, AA: ForIndex<A>>(v: &Vec<u8>, b: Build<A>) -> ConcreteRDFOntology<A, AA> {
let mut c = Cursor::new(v.clone());
horned_owl::io::rdf::reader::read_with_build(&mut c, &b, Default::default())
.unwrap()
Expand All @@ -253,21 +253,21 @@ fn food(c: &mut Criterion) {
group.bench_function("food_rc_str_rc_comp", |b| {
b.iter(|| {
let b: Build<RcStr> = Build::new();
let _: RDFOntology<RcStr, RcAnnotatedComponent> = read_vec(&food, b);
let _: ConcreteRDFOntology<RcStr, RcAnnotatedComponent> = read_vec(&food, b);
})
});

group.bench_function("food_arc_str_arc_comp", |b| {
b.iter(|| {
let b: Build<ArcStr> = Build::new();
let _: RDFOntology<ArcStr, ArcAnnotatedComponent> = read_vec(&food, b);
let _: ConcreteRDFOntology<ArcStr, ArcAnnotatedComponent> = read_vec(&food, b);
})
});

group.bench_function("food_string_direct_comp", |b| {
b.iter(|| {
let b: Build<String> = Build::new();
let _: RDFOntology<String, AnnotatedComponent<String>> = read_vec(&food, b);
let _: ConcreteRDFOntology<String, AnnotatedComponent<String>> = read_vec(&food, b);
})
});
}
Expand Down

0 comments on commit 00c3bdb

Please sign in to comment.