Benchmark Async vs Advanced event loops
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package ru.core.events;
|
||||
|
||||
import com.carrotsearch.junitbenchmarks.AbstractBenchmark;
|
||||
import mc.core.events.LoginEvent;
|
||||
import mc.core.events.async.AdvancedEventLoop;
|
||||
import mc.core.events.async.AsyncEventLoop;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import ru.core.events.handlers.AsyncEventHandler;
|
||||
|
||||
public class AsyncEventLoopBenchmark extends AbstractBenchmark {
|
||||
private static final int ITERATIONS = 50_000;
|
||||
private static AsyncEventLoop asyncEventLoop;
|
||||
private static AdvancedEventLoop advancedEventLoop;
|
||||
private static LoginEvent testEvent;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
asyncEventLoop = new AsyncEventLoop();
|
||||
asyncEventLoop.addEventHandler(new AsyncEventHandler());
|
||||
advancedEventLoop = new AdvancedEventLoop();
|
||||
advancedEventLoop.addEventHandler(new AsyncEventHandler());
|
||||
testEvent = new LoginEvent(null);
|
||||
testEvent.setDenyReason("none");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void measure() {
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
asyncEventLoop.callEvent(testEvent);
|
||||
}
|
||||
}
|
||||
|
||||
/* @Test
|
||||
@BenchmarkOptions(warmupRounds = 5, benchmarkRounds = 15)
|
||||
public void async() {
|
||||
while (true)
|
||||
asyncEventLoop.callEvent(testEvent);
|
||||
*//*for (int i = 0; i < ITERATIONS; i++) {
|
||||
asyncEventLoop.callEvent(testEvent);
|
||||
|
||||
}*//*
|
||||
}*/
|
||||
/*
|
||||
@Test
|
||||
@BenchmarkOptions(warmupRounds = 5, benchmarkRounds = 15)
|
||||
public void advanced() {
|
||||
for (int i = 0; i < ITERATIONS; i++) {
|
||||
advancedEventLoop.callEvent(testEvent);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
Reference in New Issue
Block a user