Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
allow to use this test as a crash test
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 21 Mar 2017 10:36:23 +0000 (11:36 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 21 Mar 2017 10:36:23 +0000 (11:36 +0100)
examples/java/app/pingpong/Main.java
examples/java/app/pingpong/Receiver.java
examples/java/app/pingpong/Sender.java
examples/java/app/pingpong/app_pingpong.tesh

index ed8f2a7..d933e80 100644 (file)
@@ -12,6 +12,7 @@ class Main {
   private Main() {
     throw new IllegalAccessError("Utility class");
   }
+  protected static final int TASK_COUNT = 3;
 
   public static void main(String[] args) throws HostNotFoundException {
     Msg.init(args);
index f9f8f9c..089ec45 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2006-2014. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2006-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -12,23 +11,25 @@ import org.simgrid.msg.Process;
 import org.simgrid.msg.Task;
 
 public class Receiver extends Process {
-  private static final double COMM_SIZE_BW = 100000000;
-  public Receiver(String hostname, String name, String[]args) throws HostNotFoundException {
-    super(hostname, name, args);
-  }
+       private static final double COMM_SIZE_BW = 100000000;
+       public Receiver(String hostname, String name, String[]args) throws HostNotFoundException {
+               super(hostname, name, args);
+       }
 
-  public void main(String[] args) throws MsgException {
-    Msg.info("Wait for a task");
+       public void main(String[] args) throws MsgException {
+               for (int i = 0 ; i<Main.TASK_COUNT; i++) {
+                       Msg.info("Wait for a task");
 
-    PingPongTask task = (PingPongTask)Task.receive(getHost().getName());
-    double timeGot = Msg.getClock();
-    double timeSent = task.getTime();
+                       PingPongTask task = (PingPongTask)Task.receive(getHost().getName());
+                       double timeGot = Msg.getClock();
+                       double timeSent = task.getTime();
 
-    Msg.info("Got one that was sent at time "+ timeSent);
+                       Msg.info("Got one that was sent at time "+ timeSent);
 
-    double communicationTime = timeGot - timeSent;
-    Msg.info("Communication time : " + communicationTime);
-    Msg.info(" --- bw "+ COMM_SIZE_BW/communicationTime + " ----");
-    Msg.info("Done.");
-  }
+                       double communicationTime = timeGot - timeSent;
+                       Msg.info("Communication time : " + communicationTime);
+                       Msg.info(" --- bw "+ COMM_SIZE_BW/communicationTime + " ----");
+               }
+               Msg.info("Done.");
+       }
 }
\ No newline at end of file
index e207e25..10afd57 100644 (file)
@@ -20,16 +20,18 @@ public class Sender extends Process {
        public void main(String[] args) throws MsgException {
                Msg.info("Host count: " + args.length);
 
-               for(int pos = 0; pos < args.length ; pos++) {
-                       String hostname = Host.getByName(args[pos]).getName(); // Make sure that this host exists
-                       
-                       double time = Msg.getClock(); 
-                       Msg.info("sender time: " + time);
-
-                       PingPongTask task = new PingPongTask("no name", /* Duration: 0 flops */ 0, COMM_SIZE_LAT, time);
-                       task.send(hostname);
-               }
+               for (int i = 0 ; i<Main.TASK_COUNT; i++) {
+
+                       for(int pos = 0; pos < args.length ; pos++) {
+                               String hostname = Host.getByName(args[pos]).getName(); // Make sure that this host exists
 
+                               double time = Msg.getClock(); 
+                               Msg.info("sender time: " + time);
+
+                               PingPongTask task = new PingPongTask("no name", /* Duration: 0 flops */ 0, COMM_SIZE_LAT, time);
+                               task.send(hostname);
+                       }
+               }
                Msg.info("Done.");
        }
 }
\ No newline at end of file
index 08b1a15..51e858b 100644 (file)
@@ -8,6 +8,16 @@ $ java -classpath ${classpath:=.} app/pingpong/Main ${srcdir:=.}/../platforms/sm
 > [Boivin:Receiver:(2) 1.048882] [java/INFO] Got one that was sent at time 0.0
 > [Boivin:Receiver:(2) 1.048882] [java/INFO] Communication time : 1.0488818628325232
 > [Boivin:Receiver:(2) 1.048882] [java/INFO]  --- bw 9.533962169004269E7 ----
-> [Boivin:Receiver:(2) 1.048882] [java/INFO] Done.
-> [Jacquelin:Sender:(1) 1.048882] [java/INFO] Done.
-> [1.048882] [java/INFO] MSG_main finished; Cleaning up the simulation...
+> [Boivin:Receiver:(2) 1.048882] [java/INFO] Wait for a task
+> [Jacquelin:Sender:(1) 1.048882] [java/INFO] sender time: 1.0488818628325232
+> [Boivin:Receiver:(2) 2.097764] [java/INFO] Got one that was sent at time 1.0488818628325232
+> [Boivin:Receiver:(2) 2.097764] [java/INFO] Communication time : 1.0488818628325232
+> [Boivin:Receiver:(2) 2.097764] [java/INFO]  --- bw 9.533962169004269E7 ----
+> [Boivin:Receiver:(2) 2.097764] [java/INFO] Wait for a task
+> [Jacquelin:Sender:(1) 2.097764] [java/INFO] sender time: 2.0977637256650463
+> [Boivin:Receiver:(2) 3.146646] [java/INFO] Got one that was sent at time 2.0977637256650463
+> [Boivin:Receiver:(2) 3.146646] [java/INFO] Communication time : 1.0488818628325234
+> [Boivin:Receiver:(2) 3.146646] [java/INFO]  --- bw 9.533962169004266E7 ----
+> [Boivin:Receiver:(2) 3.146646] [java/INFO] Done.
+> [Jacquelin:Sender:(1) 3.146646] [java/INFO] Done.
+> [3.146646] [java/INFO] MSG_main finished; Cleaning up the simulation...