30 maxbinsmeglobal_ (
""),
31 maxbinsmesubsys_ (
""),
67 std::string
path =
"";
68 std::string subsystemname =
"";
69 std::string subfoldername =
"";
70 size_t subsysStringEnd = 0, subfolderStringEnd = 0;
73 std::vector<MonitorElement*> melist;
79 typedef std::vector <MonitorElement*>::iterator meIt;
80 for(meIt it = melist.begin(); it != melist.end(); ++it) {
84 !( (*it)->getLumiFlag() ) )
continue;
87 std::string path = (*it)->getPathname();
90 if( 0 == path.size() )
continue;
92 subsysStringEnd = path.find(
'/', 0 );
93 if( std::string::npos == subsysStringEnd ) subsysStringEnd = path.size();
96 if( path.substr( 0, subsysStringEnd ) != subsystemname ) {
98 subsystemname = path.substr( 0, subsysStringEnd );
100 dqmStoreStatsTopLevel.push_back( aSubsystem );
104 if( path.size() == subsysStringEnd ) {
108 dqmStoreStatsTopLevel.back().push_back( aSubfolder );
114 subfolderStringEnd = path.find(
'/', subsysStringEnd + 1 );
115 if( std::string::npos == subfolderStringEnd ) subfolderStringEnd = path.size();
118 if( path.substr( subsysStringEnd + 1, subfolderStringEnd - subsysStringEnd - 1 ) != subfoldername ) {
119 subfoldername = path.substr( subsysStringEnd + 1, subfolderStringEnd - subsysStringEnd - 1 );
122 dqmStoreStatsTopLevel.back().push_back( aSubfolder );
130 switch( (*it)->kind() ) {
146 currentSubfolder.
AddBinsF( (*it)->getNbinsX() * (*it)->getNbinsY() * (*it)->getNbinsZ() );
break;
164 std::cout <<
"===========================================================================================" << std::endl;
165 std::cout <<
"[DQMStoreStats::calcstats] -- Dumping stats results ";
168 std::cout <<
"===========================================================================================" << std::endl;
171 std::cout <<
"------------------------------------------------------------------------------------------" << std::endl;
172 std::cout <<
"Configuration:" << std::endl;
173 std::cout <<
"------------------------------------------------------------------------------------------" << std::endl;
183 std::cout <<
"------------------------------------------------------------------------------------------" << std::endl;
184 std::cout <<
"Top level folder tree:" << std::endl;
185 std::cout <<
"------------------------------------------------------------------------------------------" << std::endl;
186 for( DQMStoreStatsTopLevel::const_iterator it0 = dqmStoreStatsTopLevel.begin(); it0 < dqmStoreStatsTopLevel.end(); ++it0 ) {
187 std::cout << it0->subsystemName_ <<
" (subsystem)" << std::endl;
189 for( DQMStoreStatsSubsystem::const_iterator it1 = it0->begin(); it1 < it0->end(); ++it1 ) {
190 std::cout <<
" |--> " << it1->subfolderName_ <<
" (subfolder)" << std::endl;
197 unsigned int overallNHistograms = 0, overallNBins = 0, overallNBytes = 0;
200 std::cout <<
"------------------------------------------------------------------------------------------" << std::endl;
201 std::cout <<
"Detailed ressource usage information ";
204 std::cout <<
"------------------------------------------------------------------------------------------" << std::endl;
205 std::cout <<
"subsystem/folder histograms bins bins per MB kB per" << std::endl;
206 std::cout <<
" (total) (total) histogram (total) histogram " << std::endl;
207 std::cout <<
"------------------------------------------------------------------------------------------" << std::endl;
208 for( DQMStoreStatsTopLevel::const_iterator it0 = dqmStoreStatsTopLevel.begin(); it0 < dqmStoreStatsTopLevel.end(); ++it0 ) {
209 std::cout << it0->subsystemName_ << std::endl;
211 unsigned int nHistograms = 0, nBins = 0, nBytes = 0;
213 for( DQMStoreStatsSubsystem::const_iterator it1 = it0->begin(); it1 < it0->end(); ++it1 ) {
216 std::string thisSubfolderName( it1->subfolderName_ );
217 if( thisSubfolderName.size() > 30 ) {
218 thisSubfolderName.resize( 30 );
219 thisSubfolderName.replace( thisSubfolderName.size() - 3, 3, 3,
'.' );
222 std::cout <<
" -> " << std::setw( 30 ) << std::left << thisSubfolderName;
223 std::cout << std::setw( 7 ) << std::right << it1->totalHistos_;
224 std::cout << std::setw( 12 ) << std::right << it1->totalBins_;
227 if( it1->totalHistos_ ) {
228 std::cout << std::setw( 12 ) << std::right << std::setprecision( 3 ) << it1->totalBins_ / float( it1->totalHistos_ );
230 else std::cout << std::setw( 12 ) << std::right <<
"-";
232 std::cout << std::setw( 12 ) << std::right << std::setprecision( 3 ) << it1->totalMemory_ / 1024. / 1000.;
235 if( it1->totalHistos_ ) {
236 std::cout << std::setw( 12 ) << std::right << std::setprecision( 3 ) << it1->totalMemory_ / 1024. / it1->totalHistos_;
238 else std::cout << std::setw( 12 ) << std::right <<
"-";
243 nHistograms += it1->totalHistos_;
244 nBins += it1->totalBins_;
245 nBytes += it1->totalMemory_;
252 overallNHistograms += nHistograms;
253 overallNBins += nBins;
254 overallNBytes += nBytes;
257 std::cout <<
" " << std::setw( 30 ) << std::left <<
"SUBSYSTEM TOTAL";
258 std::cout << std::setw( 7 ) << std::right << nHistograms;
259 std::cout << std::setw( 12 ) << std::right << nBins;
260 std::cout << std::setw( 12 ) << std::right << std::setprecision( 3 ) << nBins / float( nHistograms );
261 std::cout << std::setw( 12 ) << std::right << std::setprecision( 3 ) << nBytes / 1024. / 1000.;
262 std::cout << std::setw( 12 ) << std::right << std::setprecision( 3 ) << nBytes / 1024. / nHistograms;
265 std::cout <<
".........................................................................................." << std::endl;
272 std::cout <<
"------------------------------------------------------------------------------------------" << std::endl;
276 std::cout <<
"------------------------------------------------------------------------------------------" << std::endl;
277 std::cout <<
"Number of subsystems: " << dqmStoreStatsTopLevel.size() << std::endl;
278 std::cout <<
"Total number of histograms: " << overallNHistograms <<
" with: " << overallNBins <<
" bins alltogether" << std::endl;
279 std::cout <<
"Total memory occupied by histograms (excl. overhead): " << overallNBytes / 1024. / 1000. <<
" MB" << std::endl;
284 std::cout <<
"===========================================================================================" << std::endl;
285 std::cout <<
"[DQMStoreStats::calcstats] -- End of output ";
288 std::cout <<
"===========================================================================================" << std::endl;
303 std::cout <<
"------------------------------------------------------------------------------------------" << std::endl;
304 std::cout <<
"Memory profile:" << std::endl;
305 std::cout <<
"------------------------------------------------------------------------------------------" << std::endl;
308 std::pair<time_t, unsigned int> maxItem( 0, 0 );
309 for( std::vector<std::pair<time_t, unsigned int> >::const_iterator it =
memoryHistoryVector_.begin();
311 if( it->second > maxItem.second ) {
316 std::stringstream rootOutputFileName;
317 rootOutputFileName <<
"dqmStoreStats_memProfile_" << getpid() <<
".root";
322 TFile
outputFile( rootOutputFileName.str().c_str(),
"RECREATE" );
327 TTree memHistoryTree(
"dqmstorestats_memhistory",
"memory history" );
328 memHistoryTree.Branch(
"seconds", &aTime,
"seconds/I" );
329 memHistoryTree.Branch(
"megabytes", &aMb,
"megabytes/F" );
330 for( std::vector<std::pair<time_t, unsigned int> >::const_iterator it =
memoryHistoryVector_.begin();
333 aMb = it->second / 1000.;
334 memHistoryTree.Fill();
342 std::cout <<
"Approx. maximum total virtual memory size of job: ";
345 <<
" MB (reached " << maxItem.first -
startingTime_ <<
" sec. after constructor called)," << std::endl;
348 std::cout <<
"(could not be determined)" << std::endl;
385 std::string readBuffer(
"" );
386 unsigned int memSize = 0;
389 while( !procFile.eof() ) {
390 procFile >> readBuffer;
391 if( std::string(
"VmSize:" ) == readBuffer ) {
398 return std::pair<time_t, unsigned int>(
time( 0 ), memSize );
401 return std::pair<time_t, unsigned int>( 0, 0 );
421 if( procFile.good() ) {
425 std::cerr <<
" [DQMStoreStats::beginJob] ** WARNING: could not open file: " <<
procFileName_.str() << std::endl;
426 std::cerr <<
" Total memory profile will not be available." << std::endl;
std::string subfolderName_
T getUntrackedParameter(std::string const &, T const &) const
void beginRun(const edm::Run &r, const edm::EventSetup &c)
std::vector< std::pair< time_t, unsigned int > > memoryHistoryVector_
std::vector< MonitorElement * > getMatchingContents(const std::string &pattern, lat::Regexp::Syntax syntaxType=lat::Regexp::Wildcard) const
std::string subsystemName_
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
void AddBinsD(unsigned int nBins)
void endRun(const edm::Run &r, const edm::EventSetup &c)
bool isOpenProcFileSuccessful_
std::pair< unsigned int, unsigned int > readMemoryEntry(void) const
std::string pathnamematch_
std::string maxbinsmesubsys_
DQMStoreStats(const edm::ParameterSet &)
edm::ParameterSet parameters_
void dumpMemoryProfile(void)
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
std::stringstream procFileName_
void analyze(const edm::Event &e, const edm::EventSetup &c)
void AddBinsS(unsigned int nBins)
void AddBinsF(unsigned int nBins)