Reduced length of thunder tests

This commit is contained in:
Minecon724 2024-09-27 12:34:28 +02:00
parent 9777e5c5b1
commit d6d41fccd3
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8
3 changed files with 10 additions and 13 deletions

View file

@ -15,9 +15,7 @@ public class BlitzortungTest {
ThunderProvider provider = new BlitzortungProvider(); ThunderProvider provider = new BlitzortungProvider();
provider.registerStrikeHandler(coordinates -> { provider.registerStrikeHandler(coordinatesList::add);
coordinatesList.add(coordinates);
});
provider.init(); provider.init();
@ -28,10 +26,10 @@ public class BlitzortungTest {
int size = coordinatesList.size(); int size = coordinatesList.size();
if (size > 0) if (size > 0)
System.out.printf("Last from tick: %f %f (total %d)\n", coordinatesList.get(size-1).latitude, coordinatesList.get(size-1).longitude, size); System.out.printf("Last from tick: %f %f (total %d)\n", coordinatesList.get(size-1).latitude, coordinatesList.get(size-1).longitude, size);
Thread.sleep(100); Thread.sleep(25);
} }
System.out.printf("Strikes in the last 10s: %d\n", coordinatesList.size()); System.out.printf("Strikes in the last 3s: %d\n", coordinatesList.size());
System.out.printf("Latency: %dms\n", provider.getLatency()); System.out.printf("Latency: %dms\n", provider.getLatency());
} }

View file

@ -27,7 +27,7 @@ public class MockThunderProvider extends ThunderProvider {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
for (int i=0; i<40; i++) { for (int i=0; i<40; i++) {
strikes.add(new TimedStrike(now + i * 100, strikes.add(new TimedStrike(now + i * 50,
new Coordinates( new Coordinates(
rnd.nextDouble(-90, 90), rnd.nextDouble(-90, 90),
rnd.nextDouble(-180, 180) rnd.nextDouble(-180, 180)
@ -46,7 +46,7 @@ public class MockThunderProvider extends ThunderProvider {
public void tick() { public void tick() {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
while (strikes.size() > 0) { while (!strikes.isEmpty()) {
TimedStrike str = strikes.get(0); TimedStrike str = strikes.get(0);
if (now > str.timestamp) { if (now > str.timestamp) {
System.out.printf("mock thunder given: %d\n", str.timestamp); System.out.printf("mock thunder given: %d\n", str.timestamp);

View file

@ -14,8 +14,7 @@ public class ThunderProviderTest {
ThunderProvider provider = new MockThunderProvider(); ThunderProvider provider = new MockThunderProvider();
provider.registerStrikeHandler(coordinates -> provider.registerStrikeHandler(coordinatesList::add);
coordinatesList.add(coordinates));
provider.init(); provider.init();
@ -26,14 +25,14 @@ public class ThunderProviderTest {
int size = coordinatesList.size(); int size = coordinatesList.size();
if (size > 0) if (size > 0)
System.out.printf("Last from tick: %f %f (total %d)\n", coordinatesList.get(size-1).latitude, coordinatesList.get(size-1).longitude, size); System.out.printf("Last from tick: %f %f (total %d)\n", coordinatesList.get(size-1).latitude, coordinatesList.get(size-1).longitude, size);
Thread.sleep(50); Thread.sleep(20);
} }
provider.stop(); provider.stop();
System.out.printf("Strikes in the last 2.5s: %d\n", coordinatesList.size()); System.out.printf("Strikes in the last 1s: %d\n", coordinatesList.size());
System.out.printf("Latency: %dms\n", provider.getLatency()); System.out.printf("Latency: %dms\n", provider.getLatency());
assert coordinatesList.size() == 25; // TODO this is time sensitive and fails under loaded system assert coordinatesList.size() == 20; // TODO this is time sensitive and fails under loaded system. Also, the entire test is suboptimal
} }
} }