| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

# SequencerTimerTool.cpp

Go to the documentation of this file.

    00001 // $Id: SequencerTimerTool.cpp,v 1.12 2007/01/10 16:33:32 hmd Exp $
    00002 // Include files
    00003
    00004 // from Gaudi
    00005 #include "GaudiKernel/ToolFactory.h"
    00006 #include "GaudiKernel/RndmGenerators.h"
    00007 #include "GaudiKernel/IRndmGenSvc.h"
    00008
    00009 // local
    00010 #include "SequencerTimerTool.h"
    00011
    00012 //-----------------------------------------------------------------------------
    00013 // Implementation file for class : SequencerTimerTool
    00014 //
    00015 // 2004-05-19 : Olivier Callot
    00016 //-----------------------------------------------------------------------------
    00017
    00018 // Declaration of the Tool Factory
    00019 DECLARE_TOOL_FACTORY(SequencerTimerTool)
    00020
    00021 //=============================================================================
    00022 // Standard constructor, initializes variables
    00023 //=============================================================================
    00024 SequencerTimerTool::SequencerTimerTool( const std::string& type,
    00025                                         const std::string& name,
    00026                                         const IInterface* parent )
    00027   : GaudiTool ( type, name , parent )
    00028   , m_indent( 0 )
    00029   , m_normFactor( 0.001 )
    00030 {
    00031   declareInterface<ISequencerTimerTool>(this);
    00032
    00033   m_shots = 3500000 ; // 1s on 2.8GHz Xeon, gcc 3.2, -o2
    00034   declareProperty( "shots"        , m_shots );
    00035   declareProperty( "Normalised"   , m_normalised = false );
    00036   declareProperty( "GlobalTiming" , m_globalTiming = false );
    00037   declareProperty( "NameSize"     , m_headerSize = 30, "Number of characters to be used in algorithm name column" );
    00038 }
    00039 //=============================================================================
    00040 // Destructor
    00041 //=============================================================================
    00042 SequencerTimerTool::~SequencerTimerTool() {}
    00043
    00044
    00045 //=========================================================================
    00046 //
    00047 //=========================================================================
    00048 StatusCode SequencerTimerTool::initialize ( ) {
    00049   GaudiTool::initialize();
    00050   double sum = 0;
    00051   TimerForSequencer norm( "normalize", m_normFactor );
    00052   norm.start();
    00053   IRndmGenSvc* rsvc = svc<IRndmGenSvc>( "RndmGenSvc", true );
    00054   { // Use dummy loop suggested by Vanya Belyaev:
    00055     Rndm::Numbers gauss;
    00056     gauss.initialize( rsvc , Rndm::Gauss(0.,1.0) ).ignore();
    00057     unsigned int shots = m_shots;
    00058     while( 0 < --shots ) { sum += gauss() * sum ; }
    00059   }
    00060   norm.stop();
    00061   double time = norm.lastCpu();
    00062   m_speedRatio = 1./time;
    00063   info() << "This machine has a speed about "
    00064          << format( "%6.2f", 1000.*m_speedRatio)
    00065          << " times the speed of a 2.8 GHz Xeon." << endmsg ;
    00066    if ( m_normalised ) {
    00067     m_normFactor = m_speedRatio;
    00068   }
    00069   return StatusCode::SUCCESS;
    00070 }
    00071 //=========================================================================
    00072 //  Finalize : Report timers
    00073 //=========================================================================
    00074 StatusCode SequencerTimerTool::finalize ( ) {
    00075
    00076   std::string line(m_headerSize + 68, '-');
    00077   info() << line << endmsg
    00078          << "This machine has a speed about "
    00079          << format( "%6.2f", 1000.*m_speedRatio)
    00080          << " times the speed of a 2.8 GHz Xeon.";
    00081   if ( m_normalised ) info() <<" *** All times are renormalized ***";
    00082   info() << endmsg << TimerForSequencer::header( m_headerSize ) << endmsg
    00083          << line << endmsg;
    00084
    00085   std::string lastName = "";
    00086   for ( unsigned int kk=0 ; m_timerList.size() > kk ; kk++ ) {
    00087     if ( lastName == m_timerList[kk].name() ) continue; // suppress duplicate
    00088     lastName = m_timerList[kk].name();
    00089     info() << m_timerList[kk] << endmsg;
    00090   }
    00091   info() << line << endmsg;
    00092
    00093   return GaudiTool::finalize();
    00094 }
    00095
    00096 //=========================================================================
    00097 //  Return the index of a specified name. Trailing and leading spaces ignored
    00098 //=========================================================================
    00099 int SequencerTimerTool::indexByName ( std::string name ) {
    00100   std::string::size_type beg = name.find_first_not_of(" \t");
    00101   std::string::size_type end = name.find_last_not_of(" \t");
    00102   std::string temp = name.substr( beg, end-beg+1 );
    00103   for ( unsigned int kk=0 ; m_timerList.size() > kk ; kk++ ) {
    00104     beg =  m_timerList[kk].name().find_first_not_of(" \t");
    00105     end =  m_timerList[kk].name().find_last_not_of(" \t");
    00106     if ( m_timerList[kk].name().substr(beg,end-beg+1) == temp ) return kk;
    00107   }
    00108   return -1;
    00109 }
    00110 //=============================================================================

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines