-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathio_read.rs
More file actions
77 lines (69 loc) · 2.89 KB
/
Copy pathio_read.rs
File metadata and controls
77 lines (69 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use criterion::{AxisScale, BenchmarkId, Criterion, PlotConfiguration, criterion_group};
use horned_bin::generate_big_owl;
use horned_owl::io::{ParserConfiguration, RDFParserConfiguration};
use horned_owl::model::RcStr;
use horned_owl::ontology::set::SetOntology;
use std::fs::{File, create_dir_all};
use std::io::BufReader;
use std::time::Duration;
fn bench_io_read(c: &mut Criterion) {
let mut group = c.benchmark_group("io_read");
group.plot_config(PlotConfiguration::default().summary_scale(AxisScale::Logarithmic));
create_dir_all("target/bench-data").unwrap();
// These files are generated by make bench-prepare from root directory of the project
for n in [10, 100, 1_000, 2500, 5000, 10_000].iter() {
let generate_if_needed = |filename, n: &isize, format| {
let f = File::create_new(filename);
// if the file is created, fill it, or do nothing
if let Ok(mut f) = f {
generate_big_owl(*n, format, &mut f).unwrap();
}
};
let filename = format!("target/bench-data/o{}.owl", n);
generate_if_needed(filename.clone(), n, "owl");
group.bench_function(BenchmarkId::new("owl_io_read", n), |b| {
b.iter(|| {
let f = File::open(filename.clone()).ok().unwrap();
let mut f = BufReader::new(f);
let _ = horned_owl::io::rdf::reader::read(&mut f, Default::default()).ok();
})
});
let filename = format!("target/bench-data/o{}.owx", n);
generate_if_needed(filename.clone(), n, "owx");
group.bench_function(BenchmarkId::new("owx_io_read", n), |b| {
b.iter(|| {
let f = File::open(filename.clone()).ok().unwrap();
let mut f = BufReader::new(f);
let _: (SetOntology<RcStr>, _) =
horned_owl::io::owx::reader::read(&mut f, Default::default())
.ok()
.unwrap();
})
});
let filename = format!("target/bench-data/o{}.ttl", n);
generate_if_needed(filename.clone(), n, "ttl");
group.bench_function(BenchmarkId::new("ttl_io_read", n), |b| {
b.iter(|| {
let f = File::open(filename.clone()).ok().unwrap();
let mut f = BufReader::new(f);
let _ = horned_owl::io::rdf::reader::read(
&mut f,
ParserConfiguration {
rdf: RDFParserConfiguration {
format: Some(oxrdfio::RdfFormat::Turtle),
},
..Default::default()
},
)
.ok();
})
});
}
}
criterion_group! {
name = io_read;
config = Criterion::default()
.sample_size(50)
.measurement_time(Duration::from_secs(20));
targets = bench_io_read
}