Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:47

0001 #include "FWCore/MessageService/test/MemoryTestClient_B.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "FWCore/Framework/interface/MakerMacros.h"
0004 
0005 #include <iostream>
0006 #include <iomanip>
0007 #include <string>
0008 
0009 namespace edmtest
0010 {
0011  
0012 int  MemoryTestClient_B::nevent = 0;
0013 
0014 MemoryTestClient_B::MemoryTestClient_B( edm::ParameterSet const & ps)
0015   : vsize(0) 
0016 {
0017   int pattern = ps.getUntrackedParameter<int>("pattern",1);
0018   edm::LogWarning("memoryPattern") << "Memory Pattern selected: " << pattern;
0019   initializeMemoryPattern(pattern);
0020 }
0021 
0022 void
0023   MemoryTestClient_B::analyze( edm::Event      const & /*unused*/
0024                            , edm::EventSetup const & /*unused*/
0025                               )
0026 {
0027   double scale = 10;
0028   nevent++;
0029   int mevent = nevent/4;
0030   double v = memoryPattern[mevent%memoryPattern.size()];
0031   edm::LogVerbatim("memoryUsage") << "Event " << nevent 
0032     << " leaks "<< v/scale << " Mbytes";
0033   if ( v > vsize ) {
0034     int leaksize = static_cast<int>(((v-vsize)/scale)*1048576);
0035     char* leak = new  char[leaksize];
0036     edm::LogPrint("memoryIncrease") << "Event " << mevent 
0037     << " increases vsize by "<< ((v-vsize)/scale) << " Mbytes";
0038   }
0039   // DO NOT delete[] leak; the point is to increment vsize!
0040   
0041 }  // MessageLoggerClient::analyze()
0042 
0043 void  MemoryTestClient_B::initializeMemoryPattern(int pattern) {
0044   switch(pattern) {
0045     case 1:     // A general pattern
0046     memoryPattern.push_back(   2.1   );
0047     memoryPattern.push_back(   3.1   );
0048     memoryPattern.push_back(   4.1   );
0049     memoryPattern.push_back(   2.1   );
0050     memoryPattern.push_back(   1.7   );
0051     memoryPattern.push_back(   8.4   );
0052     memoryPattern.push_back(   3.4   );
0053     memoryPattern.push_back(  43.1   );
0054     memoryPattern.push_back(  17.1   );
0055     memoryPattern.push_back(   2.1   );
0056     memoryPattern.push_back(  47.9   );
0057     memoryPattern.push_back(   8.3   );
0058     memoryPattern.push_back(  56.3   );
0059     memoryPattern.push_back(   1.1   );
0060     memoryPattern.push_back(  19.1   );
0061     memoryPattern.push_back(   2.1   );
0062     memoryPattern.push_back(  22.0   );
0063     memoryPattern.push_back(   9.1   );
0064     memoryPattern.push_back(   2.1   );
0065     memoryPattern.push_back(  57.9   );
0066     memoryPattern.push_back(   2.1   );
0067     memoryPattern.push_back(  59.5   );
0068     memoryPattern.push_back(   4.1   );
0069     memoryPattern.push_back(   6.1   );
0070     memoryPattern.push_back(  61.5   );
0071     memoryPattern.push_back(   4.2   );
0072     memoryPattern.push_back(   6.3   );
0073     break;
0074     case 2:     
0075     memoryPattern.push_back(  43.1   );
0076     memoryPattern.push_back(  17.1   );
0077     memoryPattern.push_back(   2.1   );
0078     memoryPattern.push_back( 119.5   );
0079     memoryPattern.push_back(  19.5   );
0080   break;
0081     case 3:     
0082     memoryPattern.push_back(   3.1   );
0083     memoryPattern.push_back(   2.1   );
0084     memoryPattern.push_back(  47.9   );
0085     memoryPattern.push_back(   8.3   );
0086     memoryPattern.push_back(  56.3   );
0087     memoryPattern.push_back(   1.1   );
0088     memoryPattern.push_back(  19.1   );
0089     memoryPattern.push_back(   2.1   );
0090     memoryPattern.push_back(  22.0   );
0091     memoryPattern.push_back(   9.1   );
0092     memoryPattern.push_back(   2.1   );
0093     memoryPattern.push_back(  57.9   );
0094     memoryPattern.push_back(   2.1   );
0095     memoryPattern.push_back(  17.1   );
0096     break;
0097     case 4:     
0098     memoryPattern.push_back(  0   );
0099     break;
0100     default:
0101     memoryPattern.push_back(   2.1   );
0102     memoryPattern.push_back(   3.1   );
0103     memoryPattern.push_back(   4.1   );
0104     memoryPattern.push_back(   2.1   );
0105   }
0106 }
0107 
0108 }  // namespace edmtest
0109 
0110 
0111 using edmtest::MemoryTestClient_B;
0112 DEFINE_FWK_MODULE(MemoryTestClient_B);