|
|
@ -1,3 +1,5 @@ |
|
|
|
|
|
|
|
#![allow(clippy::print_stderr)] |
|
|
|
|
|
|
|
|
|
|
|
use anyhow::Result; |
|
|
|
use anyhow::Result; |
|
|
|
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; |
|
|
|
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; |
|
|
|
use oxigraph_testsuite::files::read_file; |
|
|
|
use oxigraph_testsuite::files::read_file; |
|
|
@ -40,7 +42,7 @@ fn parse_bench( |
|
|
|
c: &mut Criterion, |
|
|
|
c: &mut Criterion, |
|
|
|
parser_name: &str, |
|
|
|
parser_name: &str, |
|
|
|
data_name: &str, |
|
|
|
data_name: &str, |
|
|
|
data: Vec<u8>, |
|
|
|
data: &[u8], |
|
|
|
bench: impl Fn(&[u8]), |
|
|
|
bench: impl Fn(&[u8]), |
|
|
|
) { |
|
|
|
) { |
|
|
|
let mut group = c.benchmark_group(parser_name); |
|
|
|
let mut group = c.benchmark_group(parser_name); |
|
|
@ -51,7 +53,7 @@ fn parse_bench( |
|
|
|
group.finish(); |
|
|
|
group.finish(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn parse_oxttl_ntriples(c: &mut Criterion, name: &str, data: Vec<u8>) { |
|
|
|
fn parse_oxttl_ntriples(c: &mut Criterion, name: &str, data: &[u8]) { |
|
|
|
parse_bench(c, "oxttl ntriples", name, data, |data| { |
|
|
|
parse_bench(c, "oxttl ntriples", name, data, |data| { |
|
|
|
let mut parser = oxttl::NTriplesParser::new().parse(); |
|
|
|
let mut parser = oxttl::NTriplesParser::new().parse(); |
|
|
|
parser.extend_from_slice(data); |
|
|
|
parser.extend_from_slice(data); |
|
|
@ -62,7 +64,7 @@ fn parse_oxttl_ntriples(c: &mut Criterion, name: &str, data: Vec<u8>) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn parse_oxttl_turtle(c: &mut Criterion, name: &str, data: Vec<u8>) { |
|
|
|
fn parse_oxttl_turtle(c: &mut Criterion, name: &str, data: &[u8]) { |
|
|
|
parse_bench(c, "oxttl turtle", name, data, |data| { |
|
|
|
parse_bench(c, "oxttl turtle", name, data, |data| { |
|
|
|
let mut parser = oxttl::TurtleParser::new().parse(); |
|
|
|
let mut parser = oxttl::TurtleParser::new().parse(); |
|
|
|
parser.extend_from_slice(data); |
|
|
|
parser.extend_from_slice(data); |
|
|
@ -73,25 +75,25 @@ fn parse_oxttl_turtle(c: &mut Criterion, name: &str, data: Vec<u8>) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn parse_rio_ntriples(c: &mut Criterion, name: &str, data: Vec<u8>) { |
|
|
|
fn parse_rio_ntriples(c: &mut Criterion, name: &str, data: &[u8]) { |
|
|
|
parse_bench(c, "rio ntriples", name, data, |data| { |
|
|
|
parse_bench(c, "rio ntriples", name, data, |data| { |
|
|
|
let mut count: u64 = 0; |
|
|
|
let mut count: u64 = 0; |
|
|
|
NTriplesParser::new(data) |
|
|
|
NTriplesParser::new(data) |
|
|
|
.parse_all(&mut |_| { |
|
|
|
.parse_all::<TurtleError>(&mut |_| { |
|
|
|
count += 1; |
|
|
|
count += 1; |
|
|
|
Ok(()) as Result<(), TurtleError> |
|
|
|
Ok(()) |
|
|
|
}) |
|
|
|
}) |
|
|
|
.unwrap(); |
|
|
|
.unwrap(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn parse_rio_turtle(c: &mut Criterion, name: &str, data: Vec<u8>) { |
|
|
|
fn parse_rio_turtle(c: &mut Criterion, name: &str, data: &[u8]) { |
|
|
|
parse_bench(c, "rio turtle", name, data, |data| { |
|
|
|
parse_bench(c, "rio turtle", name, data, |data| { |
|
|
|
let mut count: u64 = 0; |
|
|
|
let mut count: u64 = 0; |
|
|
|
TurtleParser::new(data, None) |
|
|
|
TurtleParser::new(data, None) |
|
|
|
.parse_all(&mut |_| { |
|
|
|
.parse_all::<TurtleError>(&mut |_| { |
|
|
|
count += 1; |
|
|
|
count += 1; |
|
|
|
Ok(()) as Result<(), TurtleError> |
|
|
|
Ok(()) |
|
|
|
}) |
|
|
|
}) |
|
|
|
.unwrap(); |
|
|
|
.unwrap(); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -101,7 +103,7 @@ fn bench_parse_oxttl_ntriples_with_ntriples(c: &mut Criterion) { |
|
|
|
parse_oxttl_ntriples( |
|
|
|
parse_oxttl_ntriples( |
|
|
|
c, |
|
|
|
c, |
|
|
|
"ntriples", |
|
|
|
"ntriples", |
|
|
|
match ntriples_test_data() { |
|
|
|
&match ntriples_test_data() { |
|
|
|
Ok(d) => d, |
|
|
|
Ok(d) => d, |
|
|
|
Err(e) => { |
|
|
|
Err(e) => { |
|
|
|
eprintln!("{e}"); |
|
|
|
eprintln!("{e}"); |
|
|
@ -115,7 +117,7 @@ fn bench_parse_oxttl_ntriples_with_turtle(c: &mut Criterion) { |
|
|
|
parse_oxttl_turtle( |
|
|
|
parse_oxttl_turtle( |
|
|
|
c, |
|
|
|
c, |
|
|
|
"ntriples", |
|
|
|
"ntriples", |
|
|
|
match ntriples_test_data() { |
|
|
|
&match ntriples_test_data() { |
|
|
|
Ok(d) => d, |
|
|
|
Ok(d) => d, |
|
|
|
Err(e) => { |
|
|
|
Err(e) => { |
|
|
|
eprintln!("{e}"); |
|
|
|
eprintln!("{e}"); |
|
|
@ -129,7 +131,7 @@ fn bench_parse_oxttl_turtle_with_turtle(c: &mut Criterion) { |
|
|
|
parse_oxttl_turtle( |
|
|
|
parse_oxttl_turtle( |
|
|
|
c, |
|
|
|
c, |
|
|
|
"turtle", |
|
|
|
"turtle", |
|
|
|
match turtle_test_data() { |
|
|
|
&match turtle_test_data() { |
|
|
|
Ok(d) => d, |
|
|
|
Ok(d) => d, |
|
|
|
Err(e) => { |
|
|
|
Err(e) => { |
|
|
|
eprintln!("{e}"); |
|
|
|
eprintln!("{e}"); |
|
|
@ -143,7 +145,7 @@ fn bench_parse_rio_ntriples_with_ntriples(c: &mut Criterion) { |
|
|
|
parse_rio_ntriples( |
|
|
|
parse_rio_ntriples( |
|
|
|
c, |
|
|
|
c, |
|
|
|
"ntriples", |
|
|
|
"ntriples", |
|
|
|
match ntriples_test_data() { |
|
|
|
&match ntriples_test_data() { |
|
|
|
Ok(d) => d, |
|
|
|
Ok(d) => d, |
|
|
|
Err(e) => { |
|
|
|
Err(e) => { |
|
|
|
eprintln!("{e}"); |
|
|
|
eprintln!("{e}"); |
|
|
@ -157,7 +159,7 @@ fn bench_parse_rio_ntriples_with_turtle(c: &mut Criterion) { |
|
|
|
parse_rio_turtle( |
|
|
|
parse_rio_turtle( |
|
|
|
c, |
|
|
|
c, |
|
|
|
"ntriples", |
|
|
|
"ntriples", |
|
|
|
match ntriples_test_data() { |
|
|
|
&match ntriples_test_data() { |
|
|
|
Ok(d) => d, |
|
|
|
Ok(d) => d, |
|
|
|
Err(e) => { |
|
|
|
Err(e) => { |
|
|
|
eprintln!("{e}"); |
|
|
|
eprintln!("{e}"); |
|
|
@ -171,7 +173,7 @@ fn bench_parse_rio_turtle_with_turtle(c: &mut Criterion) { |
|
|
|
parse_rio_turtle( |
|
|
|
parse_rio_turtle( |
|
|
|
c, |
|
|
|
c, |
|
|
|
"turtle", |
|
|
|
"turtle", |
|
|
|
match turtle_test_data() { |
|
|
|
&match turtle_test_data() { |
|
|
|
Ok(d) => d, |
|
|
|
Ok(d) => d, |
|
|
|
Err(e) => { |
|
|
|
Err(e) => { |
|
|
|
eprintln!("{e}"); |
|
|
|
eprintln!("{e}"); |
|
|
|