Revision: 8873
http://playerstage.svn.sourceforge.net/playerstage/?rev=8873&view=rev
Author: hsujohnhsu
Date: 2010-09-02 02:12:44 +0000 (Thu, 02 Sep 2010)
Log Message:
-----------
automatically start timer on construction. use printf so message does not
interlace from different threads
Modified Paths:
--------------
code/gazebo/branches/wg/server/Timer.cc
code/gazebo/branches/wg/server/Timer.hh
Modified: code/gazebo/branches/wg/server/Timer.cc
===================================================================
--- code/gazebo/branches/wg/server/Timer.cc 2010-09-02 01:40:11 UTC (rev
8872)
+++ code/gazebo/branches/wg/server/Timer.cc 2010-09-02 02:12:44 UTC (rev
8873)
@@ -33,6 +33,7 @@
Timer::Timer(Type t)
{
this->type = t;
+ this->Start(); // auto start on construction, should not hurt
}
////////////////////////////////////////////////////////////////////////////////
Modified: code/gazebo/branches/wg/server/Timer.hh
===================================================================
--- code/gazebo/branches/wg/server/Timer.hh 2010-09-02 01:40:11 UTC (rev
8872)
+++ code/gazebo/branches/wg/server/Timer.hh 2010-09-02 02:12:44 UTC (rev
8873)
@@ -28,6 +28,8 @@
#include "GazeboMessage.hh"
#include "Time.hh"
+#include <iostream>
+#include <iomanip>
namespace gazebo
{
@@ -56,7 +58,7 @@
public: friend std::ostream &operator<<(std::ostream &out,
const gazebo::Timer &t)
{
- out << t.GetElapsed();
+ out << std::fixed << std::setprecision(6) << t.GetElapsed();
return out;
}
@@ -73,20 +75,26 @@
{
this->name = name;
this->msgLevel = level;
- this->Report("Start @ ");
+ //this->Report("Start @ ");
}
/// \brief Destructor
public: virtual ~DiagnosticTimer()
{
- this->Report("Complete @ ");
+ this->Report("Duration: ");
}
/// \brief Report a time
public: void Report(const std::string msg)
{
- gzmsg(this->msgLevel) << this->name << "["
- << msg << *this << "]\n";
+ //switching to printf so messages do not get broken up into
interlaced pieces on multiple threads
+ //(gazebo::GazeboMessage::Instance()->Msg(this->msgLevel)) <<
this->name << "[" << msg << *this << "]\n";
+ if (gazebo::GazeboMessage::Instance()->GetVerbose() >=
this->msgLevel)
+ {
+ std::ostringstream stream;
+ stream << this->name << "[" << msg << *this << "]\n";
+ printf("%s",stream.str().c_str());
+ }
}
private: int msgLevel;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:
Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit