Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
last changes of cpp wrappers examples
[simgrid.git] / examples / cxx / ping_pong / Receiver.cxx
index fec2c36..cf58070 100644 (file)
@@ -1,46 +1,46 @@
-#include "Receiver.hpp"\r
-#include "PingPongTask.hpp"\r
-#include <Host.hpp>\r
-#include <HostNotFoundException.hpp>\r
-#include <Msg.hpp>\r
-\r
-#include <iostream>\r
-using namespace std;\r
-\r
-MSG_IMPLEMENT_DYNAMIC(Receiver, Process);\r
-\r
-const double commSizeLat = 1;\r
-const double commSizeBw = 100000000;\r
-\r
-int Receiver::main(int argc, char** argv)\r
-{\r
-       cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl;\r
-       double communicationTime=0;\r
-       double time = getClock();\r
-       \r
-       cout <<"[" << getName() << ":" << getHost().getName() << "try to get a task" << endl;\r
-       \r
-       PingPongTask* task = reinterpret_cast<PingPongTask*>(Task::get(0));\r
-       \r
-       double timeGot = getClock();\r
-       double timeSent = task->getTime();\r
-       \r
-       delete task;\r
-       \r
-       cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Got at time " << timeGot << endl;\r
-       cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Was sent at time " << timeSent << endl;\r
-       \r
-       time = timeSent;\r
-       \r
-       communicationTime = timeGot - time;\r
-       \r
-       cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Communication time : " << communicationTime << endl;\r
-       \r
-       cout <<"[" << getName() << ":" << getHost().getName() << "] " << " --- bw " << commSizeBw/communicationTime << " ----" << endl;\r
-       \r
-       cout <<"[" << getName() << ":" << getHost().getName() << "] " << "goodbye!" << endl;\r
-       \r
-       delete this;\r
-\r
-       return 0;\r
-}
\ No newline at end of file
+#include "Receiver.hpp"
+#include "PingPongTask.hpp"
+#include <Host.hpp>
+#include <HostNotFoundException.hpp>
+#include <Msg.hpp>
+
+#include <Msg.hpp>
+
+MSG_IMPLEMENT_DYNAMIC(Receiver, Process)
+
+const double commSizeLat = 1;
+const double commSizeBw = 100000000;
+
+int Receiver::main(int argc, char** argv)
+{
+       info("Hello");
+       double communicationTime=0;
+       double time = getClock();
+       StringHelper bw;
+       
+       info("Try to get a task");
+       
+       PingPongTask* task = reinterpret_cast<PingPongTask*>(Task::get(0));
+       
+       double timeGot = getClock();
+       double timeSent = task->getTime();
+       
+       delete task;
+       
+       info(TEXT_("Got at time ") + TEXT_(timeGot));
+       info(TEXT_("Was sent at time ") + TEXT_(timeSent));
+       
+       time = timeSent;
+       
+       communicationTime = timeGot - time;
+       
+       info(TEXT_( "Communication time : ") + TEXT_(communicationTime));
+       
+       info(TEXT_(" --- BW ") + bw.append(commSizeBw/communicationTime,"%07lf") + TEXT_(" ----"));
+       
+       info("Goodbye!");
+       
+       delete this;
+
+       return 0;
+}