-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathio_write.rs
More file actions
81 lines (70 loc) · 2.77 KB
/
Copy pathio_write.rs
File metadata and controls
81 lines (70 loc) · 2.77 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
78
79
80
81
use criterion::{AxisScale, BenchmarkId, Criterion, PlotConfiguration, criterion_group};
use horned_owl::model::{Build, MutableOntology, RcStr};
use horned_owl::ontology::component_mapped::RcComponentMappedOntology;
use horned_owl::ontology::set::SetOntology;
use horned_pretty_rdf::ox::WriterQuadSerializerAdaptor;
use oxrdfio::RdfSerializer;
use std::io::sink;
use std::time::Duration;
fn build_ontology(n: isize) -> RcComponentMappedOntology {
let b = Build::new_rc();
let mut o: SetOntology<RcStr> = SetOntology::new_rc();
for i in 1..=n {
o.declare(b.class(format!("https://www.example.com/o{}", i)));
}
o.into()
}
fn bench_io_write(c: &mut Criterion) {
let mut group = c.benchmark_group("io_write");
group.plot_config(PlotConfiguration::default().summary_scale(AxisScale::Logarithmic));
for n in [10, 100, 1_000, 2500, 5000, 10_000].iter() {
let ont = build_ontology(*n);
// RDF/XML: pretty formatter (horned-pretty-rdf)
group.bench_function(BenchmarkId::new("rdf_xml_pretty_io_write", n), |b| {
b.iter(|| {
horned_owl::io::rdf::writer::write(sink(), &ont).ok();
})
});
// RDF/XML: plain oxrdfio serializer
group.bench_function(BenchmarkId::new("rdf_xml_plain_io_write", n), |b| {
b.iter(|| {
let f = WriterQuadSerializerAdaptor::new(
RdfSerializer::from_format(oxrdfio::RdfFormat::RdfXml).for_writer(sink()),
);
horned_owl::io::rdf::writer::write_to_rdf_formatter(&ont, f).ok();
})
});
group.bench_function(BenchmarkId::new("ttl_io_write", n), |b| {
b.iter(|| {
horned_owl::io::rdf::writer::write_to_rdf_format(sink(), &ont, "ttl").ok();
})
});
group.bench_function(BenchmarkId::new("nt_io_write", n), |b| {
b.iter(|| {
horned_owl::io::rdf::writer::write_to_rdf_format(sink(), &ont, "nt").ok();
})
});
group.bench_function(BenchmarkId::new("owx_io_write", n), |b| {
b.iter(|| {
horned_owl::io::owx::writer::write(sink(), &ont, None).ok();
})
});
group.bench_function(BenchmarkId::new("ofn_io_write", n), |b| {
b.iter(|| {
horned_owl::io::ofn::writer::write(sink(), &ont, None).ok();
})
});
group.bench_function(BenchmarkId::new("omn_io_write", n), |b| {
b.iter(|| {
horned_owl::io::omn::writer::write(sink(), &ont, None).ok();
})
});
}
}
criterion_group! {
name = io_write;
config = Criterion::default()
.sample_size(50)
.measurement_time(Duration::from_secs(20));
targets = bench_io_write
}