From bfabce5161e988f5e61cbfae9ca08350846077c5 Mon Sep 17 00:00:00 2001 From: Vladimir Matena Date: Wed, 20 May 2015 18:00:52 +0200 Subject: [PATCH] Move ConvoyRebroadcast performance test to extra executable class --- .../ConvoyReboradcastPerformanceTest.java | 72 +++++++++++++++++++ .../demo/convoy/ConvoyRebroadcastTest.java | 51 +------------ 2 files changed, 73 insertions(+), 50 deletions(-) create mode 100644 jdeeco-network-plugin/test/cz/cuni/mff/d3s/jdeeco/network/demo/convoy/ConvoyReboradcastPerformanceTest.java diff --git a/jdeeco-network-plugin/test/cz/cuni/mff/d3s/jdeeco/network/demo/convoy/ConvoyReboradcastPerformanceTest.java b/jdeeco-network-plugin/test/cz/cuni/mff/d3s/jdeeco/network/demo/convoy/ConvoyReboradcastPerformanceTest.java new file mode 100644 index 000000000..c0bd96d30 --- /dev/null +++ b/jdeeco-network-plugin/test/cz/cuni/mff/d3s/jdeeco/network/demo/convoy/ConvoyReboradcastPerformanceTest.java @@ -0,0 +1,72 @@ +package cz.cuni.mff.d3s.jdeeco.network.demo.convoy; + +import java.util.Random; + +import cz.cuni.mff.d3s.deeco.runners.DEECoSimulation; +import cz.cuni.mff.d3s.deeco.runtime.DEECoNode; +import cz.cuni.mff.d3s.deeco.timer.DiscreteEventTimer; +import cz.cuni.mff.d3s.deeco.timer.SimulationTimer; +import cz.cuni.mff.d3s.jdeeco.core.demo.convoy.ConvoyEnsemble; +import cz.cuni.mff.d3s.jdeeco.core.demo.convoy.Follower; +import cz.cuni.mff.d3s.jdeeco.core.demo.convoy.Leader; +import cz.cuni.mff.d3s.jdeeco.network.Network; +import cz.cuni.mff.d3s.jdeeco.network.device.SimpleBroadcastDevice; +import cz.cuni.mff.d3s.jdeeco.network.l2.strategy.KnowledgeInsertingStrategy; +import cz.cuni.mff.d3s.jdeeco.network.l2.strategy.RebroadcastStrategy; +import cz.cuni.mff.d3s.jdeeco.position.PositionPlugin; +import cz.cuni.mff.d3s.jdeeco.publishing.DefaultKnowledgePublisher; + +public class ConvoyReboradcastPerformanceTest { + /** + * Tests the performance of the rebroadcast system + * + * ### This is not to be run automatically. ### + * + * Instantiates a lot of nodes and tries rebroadcast. + * + * @throws Exception + * + */ + public static void main(String[] args) throws Exception { + final long SIMULATION_DURATION_MS = 120000; + + // Create main application container + SimulationTimer simulationTimer = new DiscreteEventTimer(); // also "new WallTimeSchedulerNotifier()" + DEECoSimulation realm = new DEECoSimulation(simulationTimer); + realm.addPlugin(new SimpleBroadcastDevice(25, 5, 250, 128)); + realm.addPlugin(Network.class); + realm.addPlugin(KnowledgeInsertingStrategy.class); + realm.addPlugin(RebroadcastStrategy.class); + realm.addPlugin(DefaultKnowledgePublisher.class); + + final int PLAYGROUND_WIDTH = 1000; + final int PLAYGROUND_HEIGHT = 1000; + final int NODES = 50; + final Random rand = new Random(42); + + for (int i = 0; i < NODES; ++i) { + // Create DEECo node 1 - leader + DEECoNode deeco = realm.createNode(new PositionPlugin(rand.nextInt(PLAYGROUND_WIDTH), rand + .nextInt(PLAYGROUND_HEIGHT))); + + if (rand.nextBoolean()) { + // Deploy components and ensembles + deeco.deployComponent(new Leader("L" + i, System.out, simulationTimer)); + } else { + // Deploy components and ensembles + deeco.deployComponent(new Follower("F" + i, System.out, simulationTimer)); + } + + deeco.deployEnsemble(ConvoyEnsemble.class); + } + + long startTime = System.currentTimeMillis(); + + // Run the simulation + realm.start(SIMULATION_DURATION_MS); + + long endTime = System.currentTimeMillis(); + + System.out.format("Done, %d ms simulated in %d real ms. Sim/Real %f%n", SIMULATION_DURATION_MS, endTime - startTime, (double)(SIMULATION_DURATION_MS) / (endTime - startTime)); + } +} diff --git a/jdeeco-network-plugin/test/cz/cuni/mff/d3s/jdeeco/network/demo/convoy/ConvoyRebroadcastTest.java b/jdeeco-network-plugin/test/cz/cuni/mff/d3s/jdeeco/network/demo/convoy/ConvoyRebroadcastTest.java index bca0db4e1..174d385fd 100644 --- a/jdeeco-network-plugin/test/cz/cuni/mff/d3s/jdeeco/network/demo/convoy/ConvoyRebroadcastTest.java +++ b/jdeeco-network-plugin/test/cz/cuni/mff/d3s/jdeeco/network/demo/convoy/ConvoyRebroadcastTest.java @@ -5,9 +5,7 @@ import java.io.ByteArrayOutputStream; import java.io.PrintStream; -import java.util.Random; -import org.junit.Ignore; import org.junit.Test; import cz.cuni.mff.d3s.deeco.runners.DEECoSimulation; @@ -93,52 +91,5 @@ private void convoyRebroadcastLoopbackRunner(boolean silent) throws Exception { assertThat(baos.toString(), containsString("Follower F0: me = (1,3) leader = (1,3)")); assertThat(baos.toString(), containsString("Follower F1: me = (1,3) leader = (1,3)")); } - } - - /** - * Tests the performance of the rebroadcast system - * - * ### This is not to be run automatically. ### - * - * Instantiates a lot of nodes and tries rebroadcast. - * - * @throws Exception - * - */ - @Test - @Ignore("Please use this only to verify performance") - public void rebroadcastingPerformanceTest() throws Exception { - // Create main application container - SimulationTimer simulationTimer = new DiscreteEventTimer(); // also "new WallTimeSchedulerNotifier()" - DEECoSimulation realm = new DEECoSimulation(simulationTimer); - realm.addPlugin(new SimpleBroadcastDevice(25, 5, 250, 128)); - realm.addPlugin(Network.class); - realm.addPlugin(KnowledgeInsertingStrategy.class); - realm.addPlugin(RebroadcastStrategy.class); - realm.addPlugin(DefaultKnowledgePublisher.class); - - final int PLAYGROUND_WIDTH = 1000; - final int PLAYGROUND_HEIGHT = 1000; - final int NODES = 50; - final Random rand = new Random(42); - - for (int i = 0; i < NODES; ++i) { - // Create DEECo node 1 - leader - DEECoNode deeco = realm.createNode(new PositionPlugin(rand.nextInt(PLAYGROUND_WIDTH), rand - .nextInt(PLAYGROUND_HEIGHT))); - - if (rand.nextBoolean()) { - // Deploy components and ensembles - deeco.deployComponent(new Leader("L" + i, System.out, simulationTimer)); - } else { - // Deploy components and ensembles - deeco.deployComponent(new Follower("F" + i, System.out, simulationTimer)); - } - - deeco.deployEnsemble(ConvoyEnsemble.class); - } - - // WHEN simulation is performed - realm.start(120000); - } + } }