-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-3857 copy benchmarks from develop branch to allow us to compare pe…
…rformance accurately
- Loading branch information
1 parent
af3afc9
commit f0eb270
Showing
11 changed files
with
475 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
...emory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/ConcurrentQueryBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Eclipse RDF4J contributors. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Distribution License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
******************************************************************************/ | ||
|
||
package org.eclipse.rdf4j.sail.memory.benchmark; | ||
|
||
import java.io.InputStream; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.eclipse.rdf4j.common.transaction.IsolationLevels; | ||
import org.eclipse.rdf4j.repository.sail.SailRepository; | ||
import org.eclipse.rdf4j.repository.sail.SailRepositoryConnection; | ||
import org.eclipse.rdf4j.rio.RDFFormat; | ||
import org.eclipse.rdf4j.sail.memory.MemoryStore; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.Level; | ||
import org.openjdk.jmh.annotations.Measurement; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.annotations.TearDown; | ||
import org.openjdk.jmh.annotations.Warmup; | ||
import org.openjdk.jmh.infra.Blackhole; | ||
import org.openjdk.jmh.runner.Runner; | ||
import org.openjdk.jmh.runner.RunnerException; | ||
import org.openjdk.jmh.runner.options.Options; | ||
import org.openjdk.jmh.runner.options.OptionsBuilder; | ||
|
||
/** | ||
* @author Håvard M. Ottestad | ||
*/ | ||
@State(Scope.Benchmark) | ||
@Warmup(iterations = 5) | ||
@BenchmarkMode({ Mode.AverageTime }) | ||
@Fork(value = 1, jvmArgs = { "-Xms1G", "-Xmx1G", }) | ||
@Measurement(iterations = 5) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
public class ConcurrentQueryBenchmark extends BaseConcurrentBenchmark { | ||
|
||
private SailRepository repository; | ||
|
||
public static void main(String[] args) throws RunnerException { | ||
Options opt = new OptionsBuilder() | ||
.include("ConcurrentQueryBenchmark.*") // adapt to run other benchmark tests | ||
.forks(1) | ||
.build(); | ||
|
||
new Runner(opt).run(); | ||
} | ||
|
||
@Setup(Level.Trial) | ||
public void setup() throws Exception { | ||
super.setup(); | ||
repository = new SailRepository(new MemoryStore()); | ||
|
||
try (SailRepositoryConnection connection = repository.getConnection()) { | ||
connection.begin(IsolationLevels.NONE); | ||
try (InputStream resourceAsStream = getResourceAsStream("benchmarkFiles/datagovbe-valid.ttl")) { | ||
connection.add(resourceAsStream, RDFFormat.TURTLE); | ||
} | ||
connection.commit(); | ||
|
||
} | ||
|
||
} | ||
|
||
@TearDown(Level.Trial) | ||
public void tearDown() throws Exception { | ||
super.tearDown(); | ||
repository.shutDown(); | ||
} | ||
|
||
@Benchmark | ||
public void hasStatement(Blackhole blackhole) throws Exception { | ||
threads(100, () -> { | ||
try (SailRepositoryConnection connection = repository.getConnection()) { | ||
for (int i = 0; i < 100; i++) { | ||
boolean b = connection.hasStatement(null, null, null, true); | ||
blackhole.consume(b); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
@Benchmark | ||
public void hasStatementSharedConnection(Blackhole blackhole) throws Exception { | ||
try (SailRepositoryConnection connection = repository.getConnection()) { | ||
threads(100, () -> { | ||
for (int i = 0; i < 100; i++) { | ||
boolean b = connection.hasStatement(null, null, null, true); | ||
blackhole.consume(b); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
@Benchmark | ||
public void getNamespaces(Blackhole blackhole) throws Exception { | ||
threads(100, () -> { | ||
try (SailRepositoryConnection connection = repository.getConnection()) { | ||
for (int i = 0; i < 100; i++) { | ||
blackhole.consume(connection.getNamespaces().stream().count()); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
@Benchmark | ||
public void getNamespacesSharedConnection(Blackhole blackhole) throws Exception { | ||
try (SailRepositoryConnection connection = repository.getConnection()) { | ||
threads(100, () -> { | ||
for (int i = 0; i < 100; i++) { | ||
blackhole.consume(connection.getNamespaces().stream().count()); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.