-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Overhaul benchmarking infrastructure (#63)
Significantly reduces the overhead of benchmarking and provides more reliable real-world numbers
1 parent
76ff4ca
commit da2bba6
Showing
29 changed files
with
1,617 additions
and
743 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
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
184 changes: 0 additions & 184 deletions
184
eventbus-jmh/src/main/java/net/minecraftforge/eventbus/benchmarks/BenchmarkBase.java
This file was deleted.
Oops, something went wrong.
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
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
124 changes: 124 additions & 0 deletions
124
eventbus-jmh/src/main/java/net/minecraftforge/eventbus/benchmarks/BenchmarkUtils.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,124 @@ | ||
/* | ||
* Copyright (c) Forge Development LLC | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
package net.minecraftforge.eventbus.benchmarks; | ||
|
||
import cpw.mods.modlauncher.Launcher; | ||
import cpw.mods.modlauncher.api.ServiceRunner; | ||
import net.minecraftforge.securemodules.SecureModuleClassLoader; | ||
import net.minecraftforge.unsafe.UnsafeHacks; | ||
import org.openjdk.jmh.infra.Blackhole; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.lang.module.ModuleFinder; | ||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
public final class BenchmarkUtils { | ||
private BenchmarkUtils() {} | ||
|
||
private static final String MANAGER = "net.minecraftforge.eventbus.testjar.benchmarks.BenchmarkManager"; | ||
|
||
public static void setupTransformedEnvironment() { | ||
try { | ||
var jar = findTestJar(); | ||
|
||
setupBaseEnvironment(); | ||
|
||
System.setProperty("test.harness.game", jar.getAbsolutePath()); // Jars to put in the game layer | ||
System.setProperty("test.harness.callable", BenchmarkUtils.TestCallback.class.getName()); | ||
|
||
// Reflectively call `new Launcher().run("--launchTarget", "testharness")` to skip | ||
// some logging in Launcher#main(String[]) | ||
var launcher = Class.forName(Launcher.class.getName()); | ||
var ctr = launcher.getDeclaredConstructor(); | ||
UnsafeHacks.setAccessible(ctr); | ||
var inst = ctr.newInstance(); | ||
var main = launcher.getDeclaredMethod("run", String[].class); | ||
UnsafeHacks.setAccessible(main); | ||
main.invoke(inst, (Object) new String[] { "--launchTarget", "testharness" }); | ||
|
||
validateEnvironment(true); | ||
} catch (Exception e) { | ||
sneak(e); | ||
} | ||
} | ||
|
||
public static void setupNormalEnvironment() { | ||
setupBaseEnvironment(); | ||
validateEnvironment(false); | ||
} | ||
|
||
// Boilerplate that ModLauncher's test harness requires | ||
public static final class TestCallback { | ||
// This is reflectively called by ModLauncher's test harness launch target. The required method name and type | ||
// are hardcoded, and its containing class is defined by the system property "test.harness.callable". | ||
public static ServiceRunner supplier() { | ||
return ServiceRunner.NOOP; | ||
} | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static Consumer<Blackhole> getPostingBenchmark(String name, int multiplier) { | ||
try { | ||
return (Consumer<Blackhole>) getBenchmarkManager() | ||
.getDeclaredMethod("getPostingBenchmark", String.class, int.class) | ||
.invoke(null, name, multiplier); | ||
} catch (Exception e) { | ||
sneak(e); | ||
throw new AssertionError("Unreachable"); | ||
} | ||
} | ||
|
||
public static Runnable[] getRegistrationBenchmark(String name) { | ||
try { | ||
return (Runnable[]) getBenchmarkManager() | ||
.getDeclaredMethod("getRegistrationBenchmark", String.class) | ||
.invoke(null, name); | ||
} catch (Exception e) { | ||
sneak(e); | ||
throw new AssertionError("Unreachable"); | ||
} | ||
} | ||
|
||
private static void setupBaseEnvironment() { | ||
try { | ||
var jar = findTestJar(); | ||
var cfg = ModuleLayer.boot().configuration().resolveAndBind(ModuleFinder.of(jar.toPath()), ModuleFinder.ofSystem(), List.of("net.minecraftforge.eventbus.testjars")); | ||
var cl = new SecureModuleClassLoader("MODULE-CLASSLOADER", null, cfg, List.of(ModuleLayer.boot())); | ||
Thread.currentThread().setContextClassLoader(cl); | ||
} catch (Exception e) { | ||
sneak(e); | ||
throw new AssertionError("Unreachable"); | ||
} | ||
} | ||
|
||
private static File findTestJar() throws IOException { | ||
var jar = new File("../eventbus-test-jar/build/libs/eventbus-test-jar.jar").getCanonicalFile(); | ||
if (!jar.exists()) | ||
throw new RuntimeException("Could not find test jar at: " + jar); | ||
|
||
return jar; | ||
} | ||
|
||
private static Class<?> getBenchmarkManager() throws Exception { | ||
return Class.forName(MANAGER, false, Thread.currentThread().getContextClassLoader()); | ||
} | ||
|
||
private static void validateEnvironment(boolean shouldBeTransformed) { | ||
try { | ||
getBenchmarkManager() | ||
.getDeclaredMethod("validate", boolean.class) | ||
.invoke(null, shouldBeTransformed); | ||
} catch (Exception e) { | ||
sneak(e); | ||
} | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private static <E extends Throwable> void sneak(Throwable e) throws E { | ||
throw (E) e; | ||
} | ||
} |
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
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
21 changes: 0 additions & 21 deletions
21
...tbus-test-jar/src/main/java/net/minecraftforge/eventbus/testjar/benchmarks/Benchmark.java
This file was deleted.
Oops, something went wrong.
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
118 changes: 118 additions & 0 deletions
118
...r/src/main/java/net/minecraftforge/eventbus/testjar/benchmarks/ModLauncherBenchmarks.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,118 @@ | ||
/* | ||
* Copyright (c) Forge Development LLC | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.minecraftforge.eventbus.testjar.benchmarks; | ||
|
||
import net.minecraftforge.eventbus.api.BusBuilder; | ||
import net.minecraftforge.eventbus.api.IEventBus; | ||
import net.minecraftforge.eventbus.testjar.events.CancelableEvent; | ||
import net.minecraftforge.eventbus.testjar.events.EventWithData; | ||
import net.minecraftforge.eventbus.testjar.events.ResultEvent; | ||
import net.minecraftforge.eventbus.testjar.subscribers.SubscriberDynamic; | ||
import net.minecraftforge.eventbus.testjar.subscribers.SubscriberLambda; | ||
import net.minecraftforge.eventbus.testjar.subscribers.SubscriberMixed; | ||
import net.minecraftforge.eventbus.testjar.subscribers.SubscriberStatic; | ||
import org.openjdk.jmh.infra.Blackhole; | ||
|
||
import java.lang.invoke.MethodHandles; | ||
import java.util.ArrayDeque; | ||
import java.util.Deque; | ||
import java.util.function.Consumer; | ||
import java.util.function.IntFunction; | ||
import java.util.function.Supplier; | ||
|
||
public final class ModLauncherBenchmarks { | ||
private ModLauncherBenchmarks() {} | ||
|
||
public static final class Post { | ||
private Post() {} | ||
private static final IEventBus EVENT_BUS = BusBuilder.builder().useModLauncher().build(); | ||
|
||
public static void setup(int multiplier, Supplier<Consumer<IEventBus>> registrar) { | ||
for (int i = 0; i < multiplier; i++) | ||
registrar.get().accept(EVENT_BUS); | ||
} | ||
|
||
public static void post(Blackhole bh) { | ||
EVENT_BUS.post(new CancelableEvent()); | ||
EVENT_BUS.post(new ResultEvent()); | ||
EVENT_BUS.post(new EventWithData("Foo", 5, true)); | ||
} | ||
|
||
public static final class Factory { | ||
private Factory() {} | ||
public static final ClassFactory<IntFunction<Consumer<Blackhole>>> MIXED = new ClassFactory<>( | ||
Post.class, | ||
MethodHandles.lookup(), | ||
(lookup, cls) -> multiplier -> | ||
BenchmarkManager.setupPostingBenchmark(lookup, cls, multiplier, SubscriberMixed.Factory.REGISTER) | ||
); | ||
|
||
public static final ClassFactory<IntFunction<Consumer<Blackhole>>> DYNAMIC = new ClassFactory<>( | ||
Post.class, | ||
MethodHandles.lookup(), | ||
(lookup, cls) -> multiplier -> | ||
BenchmarkManager.setupPostingBenchmark(lookup, cls, multiplier, SubscriberDynamic.Factory.REGISTER) | ||
); | ||
|
||
public static final ClassFactory<IntFunction<Consumer<Blackhole>>> LAMBDA = new ClassFactory<>( | ||
Post.class, | ||
MethodHandles.lookup(), | ||
(lookup, cls) -> multiplier -> | ||
BenchmarkManager.setupPostingBenchmark(lookup, cls, multiplier, SubscriberLambda.Factory.REGISTER) | ||
); | ||
|
||
public static final ClassFactory<IntFunction<Consumer<Blackhole>>> STATIC = new ClassFactory<>( | ||
Post.class, | ||
MethodHandles.lookup(), | ||
(lookup, cls) -> multiplier -> | ||
BenchmarkManager.setupPostingBenchmark(lookup, cls, multiplier, SubscriberStatic.Factory.REGISTER) | ||
); | ||
} | ||
} | ||
|
||
public static final class Register { | ||
private Register() {} | ||
|
||
public static final class Dynamic extends RegistrationBenchmark { | ||
private static final IEventBus EVENT_BUS = BusBuilder.builder().useModLauncher().build(); | ||
private static final Deque<Consumer<IEventBus>> REGISTRARS = new ArrayDeque<>(BATCH_COUNT); | ||
|
||
public static void setupIteration() { | ||
setupIteration(REGISTRARS, SubscriberDynamic.Factory.REGISTER, EVENT_BUS); | ||
} | ||
|
||
public static void run() { | ||
REGISTRARS.pop().accept(EVENT_BUS); | ||
} | ||
} | ||
|
||
public static final class Lambda extends RegistrationBenchmark { | ||
private static final IEventBus EVENT_BUS = BusBuilder.builder().useModLauncher().build(); | ||
private static final Deque<Consumer<IEventBus>> REGISTRARS = new ArrayDeque<>(BATCH_COUNT); | ||
|
||
public static void setupIteration() { | ||
setupIteration(REGISTRARS, SubscriberLambda.Factory.REGISTER, EVENT_BUS); | ||
} | ||
|
||
public static void run() { | ||
REGISTRARS.pop().accept(EVENT_BUS); | ||
} | ||
} | ||
|
||
public static final class Static extends RegistrationBenchmark { | ||
private static final IEventBus EVENT_BUS = BusBuilder.builder().useModLauncher().build(); | ||
private static final Deque<Consumer<IEventBus>> REGISTRARS = new ArrayDeque<>(BATCH_COUNT); | ||
|
||
public static void setupIteration() { | ||
setupIteration(REGISTRARS, SubscriberStatic.Factory.REGISTER, EVENT_BUS); | ||
} | ||
|
||
public static void run() { | ||
REGISTRARS.pop().accept(EVENT_BUS); | ||
} | ||
} | ||
} | ||
} |
118 changes: 118 additions & 0 deletions
118
...-jar/src/main/java/net/minecraftforge/eventbus/testjar/benchmarks/NoLoaderBenchmarks.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,118 @@ | ||
/* | ||
* Copyright (c) Forge Development LLC | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.minecraftforge.eventbus.testjar.benchmarks; | ||
|
||
import net.minecraftforge.eventbus.api.BusBuilder; | ||
import net.minecraftforge.eventbus.api.IEventBus; | ||
import net.minecraftforge.eventbus.testjar.events.CancelableEvent; | ||
import net.minecraftforge.eventbus.testjar.events.EventWithData; | ||
import net.minecraftforge.eventbus.testjar.events.ResultEvent; | ||
import net.minecraftforge.eventbus.testjar.subscribers.SubscriberDynamic; | ||
import net.minecraftforge.eventbus.testjar.subscribers.SubscriberLambda; | ||
import net.minecraftforge.eventbus.testjar.subscribers.SubscriberMixed; | ||
import net.minecraftforge.eventbus.testjar.subscribers.SubscriberStatic; | ||
import org.openjdk.jmh.infra.Blackhole; | ||
|
||
import java.lang.invoke.MethodHandles; | ||
import java.util.ArrayDeque; | ||
import java.util.Deque; | ||
import java.util.function.Consumer; | ||
import java.util.function.IntFunction; | ||
import java.util.function.Supplier; | ||
|
||
public final class NoLoaderBenchmarks { | ||
private NoLoaderBenchmarks() {} | ||
|
||
public static final class Post { | ||
private Post() {} | ||
private static final IEventBus EVENT_BUS = BusBuilder.builder().build(); | ||
|
||
public static void setup(int multiplier, Supplier<Consumer<IEventBus>> registrar) { | ||
for (int i = 0; i < multiplier; i++) | ||
registrar.get().accept(EVENT_BUS); | ||
} | ||
|
||
public static void post(Blackhole bh) { | ||
EVENT_BUS.post(new CancelableEvent()); | ||
EVENT_BUS.post(new ResultEvent()); | ||
EVENT_BUS.post(new EventWithData("Foo", 5, true)); | ||
} | ||
|
||
public static final class Factory { | ||
private Factory() {} | ||
public static final ClassFactory<IntFunction<Consumer<Blackhole>>> MIXED = new ClassFactory<>( | ||
Post.class, | ||
MethodHandles.lookup(), | ||
(lookup, cls) -> multiplier -> | ||
BenchmarkManager.setupPostingBenchmark(lookup, cls, multiplier, SubscriberMixed.Factory.REGISTER) | ||
); | ||
|
||
public static final ClassFactory<IntFunction<Consumer<Blackhole>>> DYNAMIC = new ClassFactory<>( | ||
Post.class, | ||
MethodHandles.lookup(), | ||
(lookup, cls) -> multiplier -> | ||
BenchmarkManager.setupPostingBenchmark(lookup, cls, multiplier, SubscriberDynamic.Factory.REGISTER) | ||
); | ||
|
||
public static final ClassFactory<IntFunction<Consumer<Blackhole>>> LAMBDA = new ClassFactory<>( | ||
Post.class, | ||
MethodHandles.lookup(), | ||
(lookup, cls) -> multiplier -> | ||
BenchmarkManager.setupPostingBenchmark(lookup, cls, multiplier, SubscriberLambda.Factory.REGISTER) | ||
); | ||
|
||
public static final ClassFactory<IntFunction<Consumer<Blackhole>>> STATIC = new ClassFactory<>( | ||
Post.class, | ||
MethodHandles.lookup(), | ||
(lookup, cls) -> multiplier -> | ||
BenchmarkManager.setupPostingBenchmark(lookup, cls, multiplier, SubscriberStatic.Factory.REGISTER) | ||
); | ||
} | ||
} | ||
|
||
public static final class Register { | ||
private Register() {} | ||
|
||
public static final class Dynamic extends RegistrationBenchmark { | ||
private static final IEventBus EVENT_BUS = BusBuilder.builder().build(); | ||
private static final Deque<Consumer<IEventBus>> REGISTRARS = new ArrayDeque<>(BATCH_COUNT); | ||
|
||
public static void setupIteration() { | ||
setupIteration(REGISTRARS, SubscriberDynamic.Factory.REGISTER, EVENT_BUS); | ||
} | ||
|
||
public static void run() { | ||
REGISTRARS.pop().accept(EVENT_BUS); | ||
} | ||
} | ||
|
||
public static final class Lambda extends RegistrationBenchmark { | ||
private static final IEventBus EVENT_BUS = BusBuilder.builder().build(); | ||
private static final Deque<Consumer<IEventBus>> REGISTRARS = new ArrayDeque<>(BATCH_COUNT); | ||
|
||
public static void setupIteration() { | ||
setupIteration(REGISTRARS, SubscriberLambda.Factory.REGISTER, EVENT_BUS); | ||
} | ||
|
||
public static void run() { | ||
REGISTRARS.pop().accept(EVENT_BUS); | ||
} | ||
} | ||
|
||
public static final class Static extends RegistrationBenchmark { | ||
private static final IEventBus EVENT_BUS = BusBuilder.builder().build(); | ||
private static final Deque<Consumer<IEventBus>> REGISTRARS = new ArrayDeque<>(BATCH_COUNT); | ||
|
||
public static void setupIteration() { | ||
setupIteration(REGISTRARS, SubscriberStatic.Factory.REGISTER, EVENT_BUS); | ||
} | ||
|
||
public static void run() { | ||
REGISTRARS.pop().accept(EVENT_BUS); | ||
} | ||
} | ||
} | ||
} |
165 changes: 0 additions & 165 deletions
165
eventbus-test-jar/src/main/java/net/minecraftforge/eventbus/testjar/benchmarks/Post.java
This file was deleted.
Oops, something went wrong.
86 changes: 0 additions & 86 deletions
86
eventbus-test-jar/src/main/java/net/minecraftforge/eventbus/testjar/benchmarks/Register.java
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
...r/src/main/java/net/minecraftforge/eventbus/testjar/benchmarks/RegistrationBenchmark.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,46 @@ | ||
/* | ||
* Copyright (c) Forge Development LLC | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.minecraftforge.eventbus.testjar.benchmarks; | ||
|
||
import net.minecraftforge.eventbus.api.IEventBus; | ||
|
||
import java.util.Deque; | ||
import java.util.function.Consumer; | ||
|
||
public abstract class RegistrationBenchmark { | ||
// This is the number of dynamic classes to make in the setup method. | ||
// This number just needs to be high enough that we don't get a EmptyStackException | ||
// It takes a lot of memory, but it prevents optimizations in the EventBus from | ||
// invalidating out test results. Such optimizations like the duplicate prevention | ||
// on normal register(Object) calls but not on lambda calls | ||
protected static final int BATCH_COUNT = 100_000; | ||
|
||
protected static void setupIteration(Deque<Consumer<IEventBus>> registrars, | ||
ClassFactory<Consumer<IEventBus>> registrarFactory, | ||
IEventBus eventBus) { | ||
// Clear the Deque and EventBus | ||
registrars.clear(); | ||
|
||
try { | ||
var mtd = eventBus.getClass().getDeclaredMethod("clearInternalData"); | ||
mtd.setAccessible(true); | ||
mtd.invoke(eventBus); | ||
} catch (Exception e) { | ||
sneak(e); | ||
} | ||
|
||
// Fill the Deque | ||
while (registrars.size() < BATCH_COUNT) | ||
registrars.push(registrarFactory.create()); | ||
|
||
System.gc(); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private static <E extends Throwable> void sneak(Throwable e) throws E { | ||
throw (E) e; | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
...st-jar/src/main/java/net/minecraftforge/eventbus/testjar/subscribers/SubscriberMixed.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,34 @@ | ||
/* | ||
* Copyright (c) Forge Development LLC | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.minecraftforge.eventbus.testjar.subscribers; | ||
|
||
import net.minecraftforge.eventbus.api.IEventBus; | ||
|
||
import java.util.function.Consumer; | ||
import java.util.function.Supplier; | ||
|
||
public class SubscriberMixed { | ||
public static class Factory { | ||
public static final Supplier<Consumer<IEventBus>> REGISTER = Factory::create; | ||
|
||
private static Consumer<IEventBus> create() { | ||
return new Consumer<>() { | ||
private int idx = 0; | ||
|
||
@Override | ||
public void accept(IEventBus eventBus) { | ||
var registrar = switch (idx++ % 3) { | ||
case 0 -> SubscriberDynamic.Factory.REGISTER.create(); | ||
case 1 -> SubscriberStatic.Factory.REGISTER.create(); | ||
case 2 -> SubscriberLambda.Factory.REGISTER.create(); | ||
default -> throw new AssertionError(); | ||
}; | ||
registrar.accept(eventBus); | ||
} | ||
}; | ||
} | ||
} | ||
} |
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
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