2929import org .eclipse .rdf4j .benchmark .rio .util .ThemeDataSetGenerator ;
3030import org .eclipse .rdf4j .benchmark .rio .util .ThemeDataSetGenerator .Theme ;
3131import org .eclipse .rdf4j .common .transaction .IsolationLevels ;
32+ import org .eclipse .rdf4j .query .TupleQuery ;
3233import org .eclipse .rdf4j .query .explanation .Explanation ;
3334import org .eclipse .rdf4j .queryrender .sparql .TupleExprIRRenderer ;
3435import org .eclipse .rdf4j .repository .sail .SailRepository ;
5354import org .openjdk .jmh .runner .Runner ;
5455import org .openjdk .jmh .runner .RunnerException ;
5556import org .openjdk .jmh .runner .options .OptionsBuilder ;
57+ import org .openjdk .jmh .runner .options .TimeValue ;
5658
5759@ State (Scope .Benchmark )
58- @ Warmup (iterations = 1 , batchSize = 1 , timeUnit = TimeUnit .SECONDS , time = 30 )
60+ @ Warmup (iterations = 10 , batchSize = 1 , timeUnit = TimeUnit .SECONDS , time = 1 )
5961@ BenchmarkMode ({ Mode .AverageTime })
6062@ Fork (value = 1 , jvmArgs = { "-Xms32G" , "-Xmx32G" })
61- @ Measurement (iterations = 1 , batchSize = 1 , timeUnit = TimeUnit .SECONDS , time = 10 )
63+ @ Measurement (iterations = 10 , batchSize = 1 , timeUnit = TimeUnit .SECONDS , time = 1 )
6264@ OutputTimeUnit (TimeUnit .MILLISECONDS )
6365public class ThemeQueryBenchmark {
6466
@@ -72,18 +74,20 @@ public class ThemeQueryBenchmark {
7274 private static final long EXPECTED_TRIPLES_DATA_SIZE_BYTES = 1500921856L ;
7375 private static final long EXPECTED_VALUES_DATA_SIZE_BYTES = 713687040L ;
7476
75- @ Param ({ "0" , "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "10" })
77+ @ Param ({
78+ // "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
79+ "11" , "12" })
7680 public int z_queryIndex ;
7781
7882 @ Param ({
7983 "MEDICAL_RECORDS" ,
80- "SOCIAL_MEDIA" ,
81- "LIBRARY" ,
82- "ENGINEERING" ,
83- "HIGHLY_CONNECTED" ,
84- "TRAIN" ,
85- "ELECTRICAL_GRID" ,
86- "PHARMA"
84+ // "SOCIAL_MEDIA",
85+ // "LIBRARY",
86+ // "ENGINEERING",
87+ // "HIGHLY_CONNECTED",
88+ // "TRAIN",
89+ // "ELECTRICAL_GRID",
90+ // "PHARMA"
8791 })
8892 public String themeName ;
8993
@@ -97,7 +101,11 @@ public class ThemeQueryBenchmark {
97101 public static void main (String [] args ) throws RunnerException {
98102 var opt = new OptionsBuilder ()
99103 .include ("ThemeQueryBenchmark" )
100- .forks (1 )
104+ .forks (0 )
105+ .measurementTime (TimeValue .milliseconds (1000 ))
106+ .measurementIterations (10 )
107+ .measurementBatchSize (1 )
108+ .warmupIterations (0 )
101109 .build ();
102110 new Runner (opt ).run ();
103111 }
@@ -119,6 +127,26 @@ public void setup() throws IOException {
119127 }
120128 }
121129
130+ @ Benchmark
131+ public long executeQuery () {
132+ try (var connection = repository .getConnection ()) {
133+ long count ;
134+ TupleQuery tupleQuery = connection .prepareTupleQuery (query );
135+ tupleQuery .setMaxExecutionTime (10 );
136+ try (var evaluate = tupleQuery .evaluate ()) {
137+ count = evaluate
138+ .stream ()
139+ .count ();
140+ }
141+
142+ if (count != expected ) {
143+ throw new IllegalStateException ("Unexpected count: expected " + expected + " but got " + count );
144+ }
145+
146+ return count ;
147+ }
148+ }
149+
122150 private void ensureDataLoadedAndValidated () throws IOException {
123151 var expectedDbFileSizes = readExpectedDbFileSizes ();
124152 if (!hasExpectedDbFileSizes (expectedDbFileSizes )) {
@@ -285,24 +313,6 @@ public void tearDown() {
285313 storeConfig = null ;
286314 }
287315
288- @ Benchmark
289- public long executeQuery () {
290- try (var connection = repository .getConnection ()) {
291- long count ;
292- try (var evaluate = connection .prepareTupleQuery (query ).evaluate ()) {
293- count = evaluate
294- .stream ()
295- .count ();
296- }
297-
298- if (count != expected ) {
299- throw new IllegalStateException ("Unexpected count: expected " + expected + " but got " + count );
300- }
301-
302- return count ;
303- }
304- }
305-
306316 @ Test
307317 @ Disabled
308318 public void testQueryCounts () throws IOException {
@@ -346,6 +356,7 @@ public void setupVerifiesExpectedDbFileSizesInFixedStore() throws IOException {
346356 }
347357
348358 @ Test
359+ @ Disabled
349360 public void executeQueryReturnsExpectedCountForPharmaQueryTenAfterFreshGeneration () throws IOException {
350361 FileUtils .deleteDirectory (STORE_DIRECTORY );
351362 themeName = "PHARMA" ;
0 commit comments