Commits

Anonymous committed bef914b

improved content of Data classes

Comments (0)

Files changed (7)

 2007-04-04  Sebastien Binet  <binet@lblbox>
 
+	* tagging PerfMonEvent-00-00-01
+	* improved content of Data classes
+
 	* tagging PerfMonEvent-00-00-00
 	* first import (API is way far from being stable !!)
 

PerfMonEvent/PerfMonCpuData.h

 
 // STL includes
 #include <iosfwd>
+#include <vector>
+#include <string>
 
 // HepMC / CLHEP includes
 
 
 class CpuData
 { 
+  /////////////////////////////////////////////////////////////////// 
+  // Public typedefs: 
+  /////////////////////////////////////////////////////////////////// 
+ public: 
+  typedef std::vector<std::string> Tags_t;
+  typedef std::vector<float>       Timings_t;
 
   /////////////////////////////////////////////////////////////////// 
   // Public methods: 
   /// Constructor with parameters: 
 
   /// Destructor: 
-  virtual ~CpuData(); 
+  ~CpuData(); 
 
   /////////////////////////////////////////////////////////////////// 
   // Const methods: 
   /// retrieve the total (user) time spent for this event
   const float utime() const;
 
+  /// retrieve the tag names for all events
+  const Tags_t& tags() const;
+
+  /// retrieve the timings for this event
+  const Timings_t& timings() const;
+
   /////////////////////////////////////////////////////////////////// 
   // Non-const methods: 
   /////////////////////////////////////////////////////////////////// 
   /// set the total (user) time spent for this event
   void setUtime( const float utime );
 
-  /// reset internal state
+  /// set the tag names to save for all events (won't be reset by ::clear())
+  void setTags( const Tags_t& tags );
+
+  /// set the timings for this event
+  void setTimings( const Timings_t& timings );
+
+  /// reset internal state (does NOT reset the tag names !!)
   void clear();
 
   /////////////////////////////////////////////////////////////////// 
   /////////////////////////////////////////////////////////////////// 
  private: 
 
+  /// list of chrono-tags to save
+  std::vector<std::string> m_tags;
+
+  /// list of timings for each of the above tags
+  std::vector<float> m_timings;
+
   /// Total (user) time for this event (microseconds)
   float m_utime;
+
 }; 
 
 /////////////////////////////////////////////////////////////////// 
 inline const float CpuData::utime() const
 { return m_utime; }
 
+inline const CpuData::Tags_t& CpuData::tags() const
+{ return m_tags; }
+
+inline const CpuData::Timings_t& CpuData::timings() const
+{ return m_timings; }
+
 inline void CpuData::setUtime( const float utime )
 { m_utime = utime; }
 
+inline void CpuData::setTags( const CpuData::Tags_t& tags )
+{ 
+  m_tags = tags; 
+  m_timings.resize( m_tags.size() );
+}
+
+inline void CpuData::setTimings( const CpuData::Timings_t& timings )
+{ m_timings = timings; }
+
 inline void CpuData::clear()
 { 
   setUtime( -1. );

PerfMonEvent/PerfMonData.h

   /// Constructor with parameters: 
 
   /// Destructor: 
-  virtual ~Data(); 
+  ~Data(); 
 
   /////////////////////////////////////////////////////////////////// 
   // Const methods: 

PerfMonEvent/PerfMonIoData.h

   /// Constructor with parameters: 
 
   /// Destructor: 
-  virtual ~IoData(); 
+  ~IoData(); 
 
   /////////////////////////////////////////////////////////////////// 
   // Const methods: 

PerfMonEvent/PerfMonMemData.h

   /// Constructor with parameters: 
 
   /// Destructor: 
-  virtual ~MemData(); 
+  ~MemData(); 
 
   /////////////////////////////////////////////////////////////////// 
   // Const methods: 

src/PerfMonCpuData.cxx

 
 
 // STL includes
+#include <iomanip>
+#include <sstream>
 #include <ostream>
 
 // PerfMonEvent includes
 /////////////////////////////////////////////////////////////////// 
 
 CpuData::CpuData() :
-  m_utime( -1. )
+  m_tags   ( ),
+  m_timings( ),
+  m_utime  ( -1. )
 {}
 
 CpuData::CpuData( const CpuData& rhs ) :
-  m_utime( rhs.m_utime )
+  m_tags   ( rhs.m_tags    ),
+  m_timings( rhs.m_timings ),
+  m_utime  ( rhs.m_utime   )
 {}
 
 CpuData& CpuData::operator=( const CpuData& rhs )
 {
   if ( this != &rhs ) {
-    m_utime = rhs.m_utime;
+    m_tags    = rhs.m_tags;
+    m_timings = rhs.m_timings;
+    m_utime   = rhs.m_utime;
   }
   return *this;
 }
 
 std::ostream& operator<<( std::ostream& out, const PerfMon::CpuData& o )
 {
-  out << o.utime() << "\n";
+  std::ostringstream buf;
 
-  return out;
+  buf << std::right << std::scientific << std::setprecision(8);
+  for ( PerfMon::CpuData::Timings_t::const_iterator 
+	  itr  = o.timings().begin(),
+	  iEnd = o.timings().end();
+	itr != iEnd;
+	++itr ) {
+    buf << std::setw( 16 ) << *itr;
+  }
+
+  buf << std::setw( 16 ) << o.utime();
+
+  return out << buf.str() << "\n";
 }

src/PerfMonData.cxx

 std::ostream& operator<<( std::ostream& out, const PerfMon::Data& o )
 {
   out << "evt ===========\n" 
-      << "    " << o.mem()
-      << "    " << o.cpu()
-      << "    " << o.io ()
+      << "mem: " << o.mem()
+      << "cpu: " << o.cpu()
+      << "io : " << o.io ()
     ;
   return out;
 }