From 2263ff35ea8561d9ec076a89dba3ac3f3797ec1a Mon Sep 17 00:00:00 2001 From: Jan Vales Date: Mon, 10 Jun 2013 22:10:18 +0200 Subject: [PATCH] [JMS] fairer benchmark. --- runXVSM-spaces.sh | 0 .../ac/tuwien/sbc/valesriegler/group/GroupAgent.java | 12 ++++++++++-- .../valesriegler/group/jms/JMSGroupConnector.java | 5 +++++ src/main/resources/logback.xml | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) mode change 100644 => 100755 runXVSM-spaces.sh diff --git a/runXVSM-spaces.sh b/runXVSM-spaces.sh old mode 100644 new mode 100755 diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/GroupAgent.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/GroupAgent.java index 5e6c2fc..a41ee21 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/GroupAgent.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/GroupAgent.java @@ -4,9 +4,11 @@ import java.lang.management.ManagementFactory; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.concurrent.atomic.AtomicLong; import javax.jms.JMSException; import javax.swing.SwingUtilities; @@ -56,6 +58,11 @@ public class GroupAgent { public static GroupAgent groupAgent; + /** + * Benchmark stuff. + */ + public static AtomicLong startTime = new AtomicLong(); + public static void main(String[] args) { if (args.length < 1) { throw new IllegalArgumentException(USAGE); @@ -104,8 +111,9 @@ public class GroupAgent { GroupAgent.getInstance().onDeliveryGroupsCreated(groups3); GroupAgent.getInstance().onDeliveryGroupsCreated(groups1); - log.warn("Starting benchmark in 20 sec"); Thread.sleep(20000); + log.warn("Starting benchmark."); + startTime.set(new Date().getTime()); jmsnac.sendNACMsg(new BenchmarkStart()); Thread.sleep(60000); jmsnac.sendNACMsg(new BenchmarkStop()); @@ -139,7 +147,7 @@ public class GroupAgent { public List createGroups(List pizzaTypes1, String pizzeria, int number) { List newDeliveryGroups = new ArrayList<>(); final String fakeAddress = "address"; - final GroupCreationDetailsRequest gc = new GroupCreationDetailsRequest(number, 1000, pizzaTypes1, fakeAddress, + final GroupCreationDetailsRequest gc = new GroupCreationDetailsRequest(number, 100, pizzaTypes1, fakeAddress, pizzeria); for (int i = 0; i < gc.numberOfGroups; i++) { diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/jms/JMSGroupConnector.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/jms/JMSGroupConnector.java index 672c872..5950c2e 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/jms/JMSGroupConnector.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/jms/JMSGroupConnector.java @@ -1,6 +1,7 @@ package at.ac.tuwien.sbc.valesriegler.group.jms; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import javax.jms.Connection; @@ -125,6 +126,10 @@ public class JMSGroupConnector extends AbstractGroupConnector implements Message ArrayList gd = new ArrayList(); gd.add(orderDeliveredInfo.getDeliveryGroupData()); GroupAgent.getInstance().getDeliveryModel().addDeliveries(gd); + + if (GroupAgent.getInstance().getDeliveryModel().hasFinished()) { + log.warn("Finished after {} seconds", new Date().getTime() - GroupAgent.startTime.get() / 1000); + } return; } diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 17889f6..184b6a9 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -7,7 +7,7 @@ - %-30(%d{HH:mm:ss.SSS} [%thread]) %-5level %logger{32} -.- %msg%n + %-30(%d{HH:mm:ss.SSS} [%thread]) %-5level %logger{32} - %msg%n -- 2.43.0