00001
00002
00003
00004
00005 #include "GaudiKernel/ToolFactory.h"
00006 #include "GaudiKernel/RndmGenerators.h"
00007 #include "GaudiKernel/IRndmGenSvc.h"
00008
00009
00010 #include "SequencerTimerTool.h"
00011
00012
00013
00014
00015
00016
00017
00018
00019 DECLARE_TOOL_FACTORY(SequencerTimerTool)
00020
00021
00022
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 ;
00034 declareProperty( "shots" , m_shots );
00035 declareProperty( "Normalised" , m_normalised = false );
00036 declareProperty( "GlobalTiming" , m_globalTiming = false );
00037 }
00038
00039
00040
00041 SequencerTimerTool::~SequencerTimerTool() {};
00042
00043
00044
00045
00046
00047 StatusCode SequencerTimerTool::initialize ( ) {
00048 GaudiTool::initialize();
00049 double sum = 0;
00050 TimerForSequencer norm( "normalize", m_normFactor );
00051 norm.start();
00052 IRndmGenSvc* rsvc = svc<IRndmGenSvc>( "RndmGenSvc", true );
00053 {
00054 Rndm::Numbers gauss;
00055 gauss.initialize( rsvc , Rndm::Gauss(0.,1.0) ).ignore();
00056 unsigned int shots = m_shots;
00057 while( 0 < --shots ) { sum += gauss() * sum ; }
00058 }
00059 norm.stop();
00060 double time = norm.lastCpu();
00061 m_speedRatio = 1./time;
00062 info() << "This machine has a speed about "
00063 << format( "%6.2f", 1000.*m_speedRatio)
00064 << " times the speed of a 2.8 GHz Xeon." << endreq ;
00065 if ( m_normalised ) {
00066 m_normFactor = m_speedRatio;
00067 }
00068 return StatusCode::SUCCESS;
00069 }
00070
00071
00072
00073 StatusCode SequencerTimerTool::finalize ( ) {
00074
00075 std::string line(96, '-');
00076 info() << line << endreq
00077 << "This machine has a speed about "
00078 << format( "%6.2f", 1000.*m_speedRatio)
00079 << " times the speed of a 2.8 GHz Xeon.";
00080 if ( m_normalised ) info() <<" *** All times are renormalized ***";
00081 info() << endreq << m_timerList[0].header() << endreq
00082 << line << endreq;
00083
00084 std::string lastName = "";
00085 for ( unsigned int kk=0 ; m_timerList.size() > kk ; kk++ ) {
00086 if ( lastName == m_timerList[kk].name() ) continue;
00087 lastName = m_timerList[kk].name();
00088 info() << m_timerList[kk] << endreq;
00089 }
00090 info() << line << endreq;
00091
00092 return GaudiTool::finalize();
00093 }
00094
00095
00096
00097
00098 int SequencerTimerTool::indexByName ( std::string name ) {
00099 std::string::size_type beg = name.find_first_not_of(" \t");
00100 std::string::size_type end = name.find_last_not_of(" \t");
00101 std::string temp = name.substr( beg, end-beg+1 );
00102 for ( unsigned int kk=0 ; m_timerList.size() > kk ; kk++ ) {
00103 beg = m_timerList[kk].name().find_first_not_of(" \t");
00104 end = m_timerList[kk].name().find_last_not_of(" \t");
00105 if ( m_timerList[kk].name().substr(beg,end-beg+1) == temp ) return kk;
00106 }
00107 return -1;
00108 }
00109