This repository has been archived by the owner on Sep 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
projekt name change Sub qol benchmarks
- Loading branch information
Showing
16 changed files
with
219 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,36 @@ | ||
Check the [example](https://github.com/nothub/TinyPubSub/blob/master/src/test/java/cc/neckbeard/tinypubsub/example/Example.java) for a usage snippet. | ||
A tiny and fast pubsub implementation with priorities and canceling. | ||
|
||
Check the | ||
[example](https://github.com/nothub/TinyEventBus/blob/master/src/test/java/cc/neckbeard/tinypubsub/example/Example.java) | ||
for a usage snippet. | ||
|
||
--- | ||
|
||
[benchmarks](https://github.com/nothub/TinyEventBus/tree/master/src/test/java/cc/neckbeard/tinypubsub/benchmark) ( | ||
openjdk 8, xeon e3-1230 3.30ghz): | ||
|
||
``` | ||
pub | ||
subs: 1_000 | ||
pubs: 1_000 | ||
47,681,726ns (47ms) | ||
``` | ||
|
||
``` | ||
pub | ||
subs: 100 | ||
pubs: 100_000 | ||
58,357,624ns (58ms) | ||
``` | ||
|
||
``` | ||
reg | ||
subs: 1_000 | ||
2,740,465ns (2ms) | ||
``` | ||
|
||
``` | ||
del | ||
subs: 1_000 | ||
7,297,579ns (7ms) | ||
``` |
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
2 changes: 1 addition & 1 deletion
2
...ain/java/cc/neckbeard/tinypubsub/Bus.java → ...n/java/cc/neckbeard/tinyeventbus/Bus.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
2 changes: 1 addition & 1 deletion
2
.../cc/neckbeard/tinypubsub/Cancellable.java → ...c/neckbeard/tinyeventbus/Cancellable.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package cc.neckbeard.tinypubsub; | ||
package cc.neckbeard.tinyeventbus; | ||
|
||
public interface Cancellable { | ||
|
||
|
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
46 changes: 46 additions & 0 deletions
46
src/test/java/cc/neckbeard/tinyeventbus/benchmark/DelBenchmark.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 @@ | ||
package cc.neckbeard.tinyeventbus.benchmark; | ||
|
||
import cc.neckbeard.tinyeventbus.Bus; | ||
import cc.neckbeard.tinyeventbus.Sub; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.parallel.Execution; | ||
import org.junit.jupiter.api.parallel.ExecutionMode; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.IntStream; | ||
|
||
@Execution(ExecutionMode.SAME_THREAD) | ||
public class DelBenchmark { | ||
|
||
private static final Bus bus = new Bus(); | ||
|
||
@Test | ||
void benchmark() { | ||
|
||
System.out.println("del"); | ||
|
||
final int subs = 1_000; | ||
System.out.println("subs: " + subs); | ||
|
||
List<Sub<String>> listenerContainers = new ArrayList<>(); | ||
|
||
IntStream.range(0, subs).forEach(i -> listenerContainers.add(new Sub<>(0, s -> {}))); | ||
|
||
IntStream | ||
.range(0, subs) | ||
.forEach(i -> bus.reg(listenerContainers.get(i))); | ||
|
||
final long start = System.nanoTime(); | ||
|
||
IntStream | ||
.range(0, subs) | ||
.forEach(i -> bus.del(listenerContainers.get(i))); | ||
|
||
final long end = System.nanoTime() - start; | ||
|
||
System.out.printf("%,dns (%,dms)\n", end, end / 1000000); | ||
|
||
} | ||
|
||
} |
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
42 changes: 42 additions & 0 deletions
42
src/test/java/cc/neckbeard/tinyeventbus/benchmark/RegBenchmark.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,42 @@ | ||
package cc.neckbeard.tinyeventbus.benchmark; | ||
|
||
import cc.neckbeard.tinyeventbus.Bus; | ||
import cc.neckbeard.tinyeventbus.Sub; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.parallel.Execution; | ||
import org.junit.jupiter.api.parallel.ExecutionMode; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.IntStream; | ||
|
||
@Execution(ExecutionMode.SAME_THREAD) | ||
public class RegBenchmark { | ||
|
||
private static final Bus bus = new Bus(); | ||
|
||
@Test | ||
void benchmark() { | ||
|
||
System.out.println("reg"); | ||
|
||
final int subs = 1_000; | ||
System.out.println("subs: " + subs); | ||
|
||
List<Sub<String>> listenerContainers = new ArrayList<>(); | ||
|
||
IntStream.range(0, subs).forEach(i -> listenerContainers.add(new Sub<>(0, s -> {}))); | ||
|
||
final long start = System.nanoTime(); | ||
|
||
IntStream | ||
.range(0, subs) | ||
.forEach(i -> bus.reg(listenerContainers.get(i))); | ||
|
||
final long end = System.nanoTime() - start; | ||
|
||
System.out.printf("%,dns (%,dms)\n", end, end / 1000000); | ||
|
||
} | ||
|
||
} |
10 changes: 5 additions & 5 deletions
10
...neckbeard/tinypubsub/example/Example.java → ...ckbeard/tinyeventbus/example/Example.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
2 changes: 1 addition & 1 deletion
2
...kbeard/tinypubsub/tests/BooleanEvent.java → ...eard/tinyeventbus/tests/BooleanEvent.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package cc.neckbeard.tinypubsub.tests; | ||
package cc.neckbeard.tinyeventbus.tests; | ||
|
||
class BooleanEvent { | ||
|
||
|
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
Oops, something went wrong.