Skip to content

Commit

Permalink
Refactorings for additional JMH tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bgprudhomme committed Aug 25, 2024
1 parent b61be8b commit 0458da4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public void test9_connectionHandling() throws Exception {
.map(value -> vf.createStatement(iri("s1"), RDFS.LABEL, value))
.collect(Collectors.toList()));

ExecutorService executor = Executors.newFixedThreadPool(5);
ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor();
try {
for (int i = 0; i < 5; i++) {
executor.submit(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void testConcurrentAccessToNow() throws ExecutionException, InterruptedEx
int numberOfIterations = 100;
int numberOfThreads = 10;

ExecutorService executorService = Executors.newCachedThreadPool();
ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor();
try {

for (int i = 0; i < numberOfIterations; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void testConcurrentAutoInit() throws Exception {
CountDownLatch latch = new CountDownLatch(count);

for (int i = 0; i < count; i++) {
new Thread(new SailGetConnectionTask(subject, latch)).start();
Thread.ofVirtual().start(new SailGetConnectionTask(subject, latch));
}

if (!latch.await(30, TimeUnit.SECONDS)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ public void testMultithreadedAdd() throws InterruptedException {
final CountDownLatch endLatch = new CountDownLatch(numThreads);
final Set<Throwable> exceptions = ConcurrentHashMap.newKeySet();
for (int i = 0; i < numThreads; i++) {
new Thread(new Runnable() {
Thread.ofVirtual().start(new Runnable() {

private final long iterationCount = 10 + Math.round(random.nextDouble() * 100);

Expand All @@ -791,7 +791,7 @@ public void run() {
endLatch.countDown();
}
}
}).start();
});
}
startLatch.countDown();
endLatch.await();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void addMultipleThreads() throws ExecutionException, InterruptedException

MemStatementList memStatementList = new MemStatementList();

ExecutorService executorService = Executors.newCachedThreadPool();
ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor();
try {

List<? extends Future<?>> collect = partition
Expand Down Expand Up @@ -153,7 +153,7 @@ public void addMultipleThreadsAndCleanupThread() throws ExecutionException, Inte

CountDownLatch countDownLatch = new CountDownLatch(1);

ExecutorService executorService = Executors.newCachedThreadPool();
ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor();
try {

Future<?> cleanupFuture = executorService.submit(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private void parallelTest(List<List<Transaction>> list, IsolationLevels isolatio

Random r = new Random(52465534);

ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor();

try {
for (int i = 0; i < 3; i++) {
Expand Down Expand Up @@ -467,7 +467,7 @@ private void runValidationFailuresTest(Sail sail, IsolationLevels isolationLevel
deadlockDetectionThread.setDaemon(true);
deadlockDetectionThread.start();

executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
executorService = Executors.newVirtualThreadPerTaskExecutor();

Utils.loadShapeData(repository, "complexBenchmark/shacl.trig");

Expand Down

0 comments on commit 0458da4

Please sign in to comment.