-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-355 Enhance LiteCommands execution and argument resolving performa…
…nce. (#355) * Enhance LiteCommands execution and argument resolving performance. * Fix after cleanup * Fix unit test. * Add better delay and margin for CI. * Add cache for argument key and use class implementation instead lambda. * Remove jmh * Tests and then build CI * Fix scheduled chain. * Remove invalid assertions.
- Loading branch information
Showing
53 changed files
with
474 additions
and
590 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
13 changes: 0 additions & 13 deletions
13
buildSrc/src/main/kotlin/litecommands-java-benchmark.gradle.kts
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
litecommands-annotations/benchmark/dev/rollczi/litecommands/benchmark/LiteBenchmark.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
79 changes: 79 additions & 0 deletions
79
...annotations/test/dev/rollczi/litecommands/annotations/async/ParallelAsyncCommandTest.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,79 @@ | ||
package dev.rollczi.litecommands.annotations.async; | ||
|
||
import dev.rollczi.litecommands.annotations.LiteConfig; | ||
import dev.rollczi.litecommands.annotations.LiteTestSpec; | ||
import dev.rollczi.litecommands.annotations.argument.Arg; | ||
import dev.rollczi.litecommands.annotations.command.Command; | ||
import dev.rollczi.litecommands.annotations.context.Context; | ||
import dev.rollczi.litecommands.annotations.execute.Execute; | ||
import dev.rollczi.litecommands.argument.Argument; | ||
import dev.rollczi.litecommands.argument.parser.ParseResult; | ||
import dev.rollczi.litecommands.argument.resolver.ArgumentResolver; | ||
import dev.rollczi.litecommands.context.ContextResult; | ||
import dev.rollczi.litecommands.invocation.Invocation; | ||
import dev.rollczi.litecommands.scheduler.SchedulerExecutorPoolImpl; | ||
import dev.rollczi.litecommands.unit.AssertExecute; | ||
import dev.rollczi.litecommands.unit.TestSender; | ||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ParallelAsyncCommandTest extends LiteTestSpec { | ||
|
||
private static final int DELAY = 100; | ||
|
||
static LiteConfig config = builder -> builder | ||
.scheduler(new SchedulerExecutorPoolImpl("test", 50)) | ||
.context(Date.class, invocation -> ContextResult.ok(() -> { | ||
try { | ||
Thread.sleep(DELAY); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
return new Date(); | ||
})) | ||
.argumentParser(String.class, new StringArgumentResolver()); | ||
|
||
static class StringArgumentResolver extends ArgumentResolver<TestSender, String> { | ||
@Override | ||
protected ParseResult<String> parse(Invocation<TestSender> invocation, Argument<String> context, String argument) { | ||
try { | ||
Thread.sleep(DELAY); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
return ParseResult.success(argument); | ||
} | ||
} | ||
|
||
@Command(name = "async") | ||
static class TestCommand { | ||
|
||
@Async | ||
@Execute | ||
public String testAsyncArgs2(@Async @Context Date date, @Async @Arg String first, @Async @Arg String second) { | ||
return first + " " + second; | ||
} | ||
|
||
} | ||
|
||
@Test | ||
void testAsyncArgsAndMethod() { | ||
List<CompletableFuture<AssertExecute>> results = new ArrayList<>(); | ||
|
||
for (int i = 0; i < 500; i++) { | ||
results.add(platform.executeAsync("async first second")); | ||
} | ||
|
||
for (CompletableFuture<AssertExecute> result : results) { | ||
result.join() | ||
.assertSuccess("first second"); | ||
} | ||
} | ||
|
||
|
||
} |
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.