Skip to content

Commit

Permalink
add benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
hmottestad committed Jan 24, 2024
1 parent eb1376a commit 5a31ca3
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.rdf4j.common.transaction.IsolationLevels;
import org.eclipse.rdf4j.query.BindingSet;
import org.eclipse.rdf4j.query.TupleQueryResult;
import org.eclipse.rdf4j.query.explanation.Explanation;
import org.eclipse.rdf4j.repository.sail.SailRepository;
import org.eclipse.rdf4j.repository.sail.SailRepositoryConnection;
import org.eclipse.rdf4j.rio.RDFFormat;
Expand Down Expand Up @@ -67,6 +68,7 @@ public class QueryBenchmark {
private static final String query_distinct_predicates;
private static final String simple_filter_not;
private static final String wild_card_chain_with_common_ends;
private static final String sub_select;

static {
try {
Expand Down Expand Up @@ -95,6 +97,8 @@ public class QueryBenchmark {
StandardCharsets.UTF_8);
wild_card_chain_with_common_ends = IOUtils.toString(
getResourceAsStream("benchmarkFiles/wild-card-chain-with-common-ends.qr"), StandardCharsets.UTF_8);
sub_select = IOUtils.toString(
getResourceAsStream("benchmarkFiles/sub-select.qr"), StandardCharsets.UTF_8);

} catch (IOException e) {
throw new RuntimeException(e);
Expand Down Expand Up @@ -363,6 +367,15 @@ public long simple_filter_not() {
// }
// }

@Benchmark
public long subSelect() {
try (SailRepositoryConnection connection = repository.getConnection()) {
return count(connection
.prepareTupleQuery(sub_select)
.evaluate());
}
}

private static InputStream getResourceAsStream(String filename) {
return QueryBenchmark.class.getClassLoader().getResourceAsStream(filename);
}
Expand Down
38 changes: 38 additions & 0 deletions core/sail/memory/src/test/resources/benchmarkFiles/sub-select.qr
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
PREFIX ex: <http://example.com/ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dct: <http://purl.org/dc/terms/>

SELECT ?type1 ?type2 ?language2 ?mbox ?count ?identifier2 where {

?a a ?type2.
?b a ?type1.

?b dcat:dataset ?a.

?a dcat:distribution ?mbox.
?a dct:language ?language.
FILTER (?type1 != ?type2)
?a dct:identifier ?identifier.

BIND(?a as ?c)

{
select distinct ?c (count(?dist) as ?count) ?language2 where {
?c a ?type2.
?c dcat:distribution ?dist.
?c dct:language ?language2.
} group by ?c ?language2 having (?count > 2)
}

} group by ?type1 ?type2 ?language2 ?mbox ?count ?identifier2 order by ?type1 ?type2 ?language2 ?mbox ?count ?identifier2



0 comments on commit 5a31ca3

Please sign in to comment.