Commits

bi...@4525493e-7705-40b1-a816-d608a930855b  committed 1d00524

improved content of IoData class

  • Participants
  • Parent commits bef914b

Comments (0)

Files changed (4)

 2007-04-04  Sebastien Binet  <binet@lblbox>
 
+	* tagging PerfMonEvent-00-00-02
+	* improved content of IoData class 
+
 	* tagging PerfMonEvent-00-00-01
 	* improved content of Data classes
 

File PerfMonEvent/PerfMonCpuData.h

 inline void CpuData::clear()
 { 
   setUtime( -1. );
+  m_timings.clear();
 }
 
 } //> end namespace PerfMon

File PerfMonEvent/PerfMonIoData.h

 
 // STL includes
 #include <iosfwd>
-
-// HepMC / CLHEP includes
+#include <vector>
+#include <string>
 
 // Gaudi includes
 
 { 
 
   /////////////////////////////////////////////////////////////////// 
+  // Public typedefs: 
+  /////////////////////////////////////////////////////////////////// 
+ public: 
+  typedef std::vector<std::string> Tags_t;
+  typedef std::vector<float>       Timings_t;
+
+  /////////////////////////////////////////////////////////////////// 
+  // Public types: 
+  /////////////////////////////////////////////////////////////////// 
+ public: 
+  struct ReadTag  {};
+  struct WriteTag {};
+
+  /////////////////////////////////////////////////////////////////// 
   // Public methods: 
   /////////////////////////////////////////////////////////////////// 
  public: 
   /// retrieve the commit output time for this event
   const float commitTime() const;
 
+  /// retrieve the tag names for all events
+  const Tags_t& tags() const;
+
+  /// retrieve the timings for this event
+  template< class TagType >
+  const Timings_t& timings() const;
+
   /////////////////////////////////////////////////////////////////// 
   // Non-const methods: 
   /////////////////////////////////////////////////////////////////// 
   /// set the commit output time for this event
   void setCommitTime( const float time );
 
-  /// 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
+  template< class TagType >
+  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 [read] timings for each of the above tags
+  std::vector<float> m_readTimings;
+
+  /// list of [write] timings for each of the above tags
+  std::vector<float> m_writeTimings;
+
   /// Commit Output time
   float m_commitOutput;
 }; 
 inline const float IoData::commitTime() const
 { return m_commitOutput; }
 
+inline const IoData::Tags_t& IoData::tags() const
+{ return m_tags; }
+
+template <class TagType>
+inline const IoData::Timings_t& IoData::timings() const
+{ return m_writeTimings; }
+
+template <>
+inline const IoData::Timings_t& IoData::timings<IoData::ReadTag>() const
+{ return m_readTimings; }
+
+template <>
+inline const IoData::Timings_t& IoData::timings<IoData::WriteTag>() const
+{ return m_writeTimings; }
+
 inline void IoData::setCommitTime( const float time )
 { m_commitOutput = time; }
 
+inline void IoData::setTags( const IoData::Tags_t& tags )
+{ 
+  m_tags = tags; 
+  m_readTimings. resize( m_tags.size() );
+  m_writeTimings.resize( m_tags.size() );
+}
+
+template <class TagType>
+inline void IoData::setTimings( const IoData::Timings_t& timings )
+{ m_writeTimings = timings; }
+
+template <>
+inline void 
+IoData::setTimings<IoData::ReadTag>( const IoData::Timings_t& timings )
+{ m_readTimings = timings; }
+
+template <>
+inline void 
+IoData::setTimings<IoData::WriteTag>( const IoData::Timings_t& timings )
+{ m_writeTimings = timings; }
+
 inline void IoData::clear()
 { 
+  m_readTimings. clear();
+  m_writeTimings.clear();
   m_commitOutput = -1.;
 }
 

File src/PerfMonIoData.cxx

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