@@ -21,59 +21,41 @@ fn store_load(c: &mut Criterion) {
21
21
} ) ;
22
22
}
23
23
24
- /// This benchmarks measure the duration of running a simple query (1 triple pattern). Hopefully,
24
+ /// These benchmarks measure the duration of running a simple query (1 triple pattern). Hopefully,
25
25
/// this can provide insights into the "baseline" overhead of the query engine.
26
26
fn store_single_pattern ( c : & mut Criterion ) {
27
27
let runtime = Builder :: new_current_thread ( ) . enable_all ( ) . build ( ) . unwrap ( ) ;
28
28
29
29
// No Quads
30
30
c. bench_function ( "Store::query - Single Pattern / No Quads" , |b| {
31
31
let store = runtime. block_on ( prepare_store_with_generated_triples ( 0 ) ) ;
32
- b. to_async ( & runtime)
33
- . iter ( || async { trivial_query ( & store, 0 ) . await } ) ;
32
+ b. to_async ( & runtime) . iter ( || trivial_query ( & store, 0 ) ) ;
34
33
} ) ;
35
34
// One Quad
36
35
c. bench_function ( "Store::query - Single Pattern / Single Quad" , |b| {
37
36
let store = runtime. block_on ( prepare_store_with_generated_triples ( 1 ) ) ;
38
- b. to_async ( & runtime)
39
- . iter ( || async { trivial_query ( & store, 1 ) . await } ) ;
37
+ b. to_async ( & runtime) . iter ( || trivial_query ( & store, 1 ) ) ;
40
38
} ) ;
41
39
// One Record Batch
42
- c. bench_function ( "Store::query - Single Pattern / 8096 Quads" , |b| {
43
- let store = runtime. block_on ( prepare_store_with_generated_triples ( 8096 ) ) ;
44
- b. to_async ( & runtime)
45
- . iter ( || async { trivial_query ( & store, 8096 ) . await } ) ;
40
+ c. bench_function ( "Store::query - Single Pattern / 8192 Quads" , |b| {
41
+ let store = runtime. block_on ( prepare_store_with_generated_triples ( 8192 ) ) ;
42
+ b. to_async ( & runtime) . iter ( || trivial_query ( & store, 8192 ) ) ;
46
43
} ) ;
47
44
}
48
45
49
- /// This benchmarks measure the duration of running a simple query that fixes a single part of the
46
+ /// These benchmarks measure the duration of running a simple query that fixes a single part of the
50
47
/// pattern (i.e., subject, predicate, object, graph).
51
48
fn store_single_pattern_with_fixed_element ( c : & mut Criterion ) {
52
49
let runtime = Builder :: new_current_thread ( ) . enable_all ( ) . build ( ) . unwrap ( ) ;
53
50
54
- // Graph
55
- c. bench_function (
56
- "Store::query - Single Pattern With Fixed Element (graph)" ,
57
- |b| {
58
- let store = runtime. block_on ( prepare_store_with_generated_triples ( 8096 ) ) ;
59
- b. to_async ( & runtime) . iter ( || async {
60
- let result = store
61
- . query ( "SELECT ?s ?p ?o { GRAPH <http://example.com/graph0> { ?s ?p ?o } }" )
62
- . await
63
- . unwrap ( ) ;
64
- assert_number_of_results ( result, 1 ) . await ;
65
- } ) ;
66
- } ,
67
- ) ;
68
-
69
51
// Subject
70
52
c. bench_function (
71
53
"Store::query - Single Pattern With Fixed Element (subject)" ,
72
54
|b| {
73
- let store = runtime. block_on ( prepare_store_with_generated_triples ( 8096 ) ) ;
55
+ let store = runtime. block_on ( prepare_store_with_generated_triples ( 8192 ) ) ;
74
56
b. to_async ( & runtime) . iter ( || async {
75
57
let result = store
76
- . query ( "SELECT ?g ? p ?o { GRAPH ?g { <http://example.com/subject0> ?p ?o } }" )
58
+ . query ( "SELECT ?p ?o { <http://example.com/subject0> ?p ?o }" )
77
59
. await
78
60
. unwrap ( ) ;
79
61
assert_number_of_results ( result, 1 ) . await ;
@@ -85,10 +67,10 @@ fn store_single_pattern_with_fixed_element(c: &mut Criterion) {
85
67
c. bench_function (
86
68
"Store::query - Single Pattern With Fixed Element (predicate)" ,
87
69
|b| {
88
- let store = runtime. block_on ( prepare_store_with_generated_triples ( 8096 ) ) ;
70
+ let store = runtime. block_on ( prepare_store_with_generated_triples ( 8192 ) ) ;
89
71
b. to_async ( & runtime) . iter ( || async {
90
72
let result = store
91
- . query ( "SELECT ?g ? s ?o { GRAPH ?g { ? s <http://example.com/predicate0> ?o } }" )
73
+ . query ( "SELECT ?s ?o { ? s <http://example.com/predicate0> ?o }" )
92
74
. await
93
75
. unwrap ( ) ;
94
76
assert_number_of_results ( result, 1 ) . await ;
@@ -100,10 +82,10 @@ fn store_single_pattern_with_fixed_element(c: &mut Criterion) {
100
82
c. bench_function (
101
83
"Store::query - Single Pattern With Fixed Element (object)" ,
102
84
|b| {
103
- let store = runtime. block_on ( prepare_store_with_generated_triples ( 8096 ) ) ;
85
+ let store = runtime. block_on ( prepare_store_with_generated_triples ( 8192 ) ) ;
104
86
b. to_async ( & runtime) . iter ( || async {
105
87
let result = store
106
- . query ( "SELECT ?g ? s ?p { GRAPH ?g { ? s ?p <http://example.com/object0> } }" )
88
+ . query ( "SELECT ?s ?p { ? s ?p <http://example.com/object0> }" )
107
89
. await
108
90
. unwrap ( ) ;
109
91
assert_number_of_results ( result, 1 ) . await ;
@@ -130,24 +112,20 @@ async fn prepare_store_with_generated_triples(n: usize) -> Store {
130
112
131
113
fn generate_quads ( count : usize ) -> impl Iterator < Item = Quad > {
132
114
( 0 ..count) . map ( |i| {
133
- let graph = format ! ( "http://example.com/graph{}" , i) ;
134
115
let subject = format ! ( "http://example.com/subject{}" , i) ;
135
116
let predicate = format ! ( "http://example.com/predicate{}" , i) ;
136
117
let object = format ! ( "http://example.com/object{}" , i) ;
137
118
Quad :: new (
138
119
Subject :: NamedNode ( NamedNode :: new_unchecked ( subject) ) ,
139
120
NamedNode :: new_unchecked ( predicate) ,
140
121
Term :: NamedNode ( NamedNode :: new_unchecked ( object) ) ,
141
- GraphName :: NamedNode ( NamedNode :: new_unchecked ( graph ) ) ,
122
+ GraphName :: DefaultGraph ,
142
123
)
143
124
} )
144
125
}
145
126
146
127
async fn trivial_query ( store : & Store , n : usize ) {
147
- let result = store
148
- . query ( "SELECT ?s ?p ?o { GRAPH ?g { ?s ?p ?o } }" )
149
- . await
150
- . unwrap ( ) ;
128
+ let result = store. query ( "SELECT ?s ?p ?o { ?s ?p ?o }" ) . await . unwrap ( ) ;
151
129
assert_number_of_results ( result, n) . await ;
152
130
}
153
131
0 commit comments