CMS 3D CMS Logo

Typedefs | Functions | Variables

evf::utils Namespace Reference

Typedefs

typedef long long int num

Functions

void cDiv (std::ostringstream *out)
int gettimesinceboot ()
void mDiv (std::ostringstream *out, std::string name, unsigned int value)
void mDiv (std::ostringstream *out, std::string name)
void mDiv (std::ostringstream *out, std::string name, std::string value)
void printchar (const char *name, char x)
void printone (const char *name, num x)
void printonex (const char *name, num x)
void printstr (const char *name, char *x)
void printtime (const char *name, num x)
void printtimediff (const char *name, num x)
void printunsigned (const char *name, unsigned long long x)
void procCpuStat (unsigned long long &idleJiffies, unsigned long long &allJiffies)
void procStat (std::ostringstream *out)
void readchar (char *x)
void readone (num *x)
void readstr (char *x)
void readunsigned (unsigned long long *x)
void uptime (std::ostringstream *out)

Variables

num blocked
num cmaj_flt
num cmin_flt
num cpu
num cstime
num cutime
num eip
num end_code
num esp
num exit_signal
num flags
FILE * input
num it_real_value
num maj_flt
num min_flt
num nicev
num num_threads
char obuf [4096]
num pending
num pgid
num pid
num policy
num ppid
num priority
num rss
num rsslim
num rt_priority
num sid
num sigcatch
num sigign
num start_code
num start_stack
unsigned long long start_time
char state
num stimev
char tcomm [FILENAME_MAX]
long tickspersec
num tty_nr
num tty_pgrp
num utime
num vsize
num wchan
num zero1
num zero2

Typedef Documentation

typedef long long int evf::utils::num

Definition at line 71 of file procUtils.cc.


Function Documentation

void evf::utils::cDiv ( std::ostringstream *  out)

Definition at line 357 of file procUtils.cc.

Referenced by evf::FUEventProcessor::makeStaticInfo(), mDiv(), and evf::FUEventProcessor::updater().

                                    {
      *out << "</div>";
    } 
int evf::utils::gettimesinceboot ( )

Definition at line 137 of file procUtils.cc.

References tickspersec.

Referenced by printtimediff().

                           {
      FILE *procuptime;
      int sec, ssec;
      
      procuptime = fopen("/proc/uptime", "r");
      fscanf(procuptime, "%d.%ds", &sec, &ssec);
      fclose(procuptime);
      return (sec*tickspersec)+ssec;
    }
void evf::utils::mDiv ( std::ostringstream *  out,
std::string  name,
unsigned int  value 
)

Definition at line 365 of file procUtils.cc.

References cDiv(), mDiv(), and relativeConstraints::value.

                                                                        {
      mDiv(out,name);
      *out << value;
      cDiv(out);
    } 
void evf::utils::mDiv ( std::ostringstream *  out,
std::string  name 
)

Definition at line 354 of file procUtils.cc.

Referenced by evf::FUEventProcessor::makeStaticInfo(), mDiv(), and evf::FUEventProcessor::updater().

                                                    {
      *out << "<div id=\"" << name << "\">";
    }
void evf::utils::mDiv ( std::ostringstream *  out,
std::string  name,
std::string  value 
)

Definition at line 360 of file procUtils.cc.

References cDiv(), mDiv(), and relativeConstraints::value.

                                                                     {
      mDiv(out,name);
      *out << value;
      cDiv(out);
    }
void evf::utils::printchar ( const char *  name,
char  x 
)

Definition at line 133 of file procUtils.cc.

References obuf.

Referenced by procStat().

{  sprintf(obuf,"%20s: %c\n", name, x);}
void evf::utils::printone ( const char *  name,
num  x 
)

Definition at line 130 of file procUtils.cc.

References obuf.

Referenced by procStat().

{  sprintf(obuf,"%20s: %lld\n", name, x);}
void evf::utils::printonex ( const char *  name,
num  x 
)

Definition at line 131 of file procUtils.cc.

References obuf.

Referenced by procStat().

{  sprintf(obuf,"%20s: %016llx\n", name, x);}
void evf::utils::printstr ( const char *  name,
char *  x 
)

Definition at line 134 of file procUtils.cc.

References obuf.

Referenced by procStat().

{  sprintf(obuf,"%20s: %s\n", name, x);}
void evf::utils::printtime ( const char *  name,
num  x 
)

Definition at line 135 of file procUtils.cc.

References obuf, and tickspersec.

Referenced by procStat().

{  sprintf(obuf,"%20s: %f\n", name, (((double)x) / tickspersec));}
void evf::utils::printtimediff ( const char *  name,
num  x 
)

Definition at line 147 of file procUtils.cc.

References gettimesinceboot(), NULL, obuf, tickspersec, cond::rpcobgas::time, and x.

Referenced by procStat().

                                                {
      int sinceboot = gettimesinceboot();
      int running = sinceboot - x;
      time_t rt = time(NULL) - (running / tickspersec);
      char buf[1024];
      
      strftime(buf, sizeof(buf), "%m.%d %H:%M", localtime(&rt));
      sprintf(obuf,"%20s: %s (%lu.%lus)\n", name, buf, running / tickspersec, running % tickspersec);
    }
void evf::utils::printunsigned ( const char *  name,
unsigned long long  x 
)

Definition at line 132 of file procUtils.cc.

References obuf.

{  sprintf(obuf,"%20s: %llu\n", name, x);}
void evf::utils::procCpuStat ( unsigned long long &  idleJiffies,
unsigned long long &  allJiffies 
)

Definition at line 157 of file procUtils.cc.

References prof2calltree::count, cpu, input, prof2calltree::last, NULL, readone(), and readstr().

Referenced by evf::FUEventProcessor::summarize().

                                                                                     {
      //read one
      if (input==NULL)
        input = fopen("/proc/stat", "r");
      if (input==NULL) return;
      char cpu[10];
      readstr(cpu);
      int count=0;
      long long last=0;
      do {
        readone(&last);
        if (count==3) idleJiffies+=last;
        allJiffies+=last;
      }
      while (last && count++<20);
      fclose(input);
      input=NULL;
    }
void evf::utils::procStat ( std::ostringstream *  out)

Definition at line 176 of file procUtils.cc.

References blocked, cmaj_flt, cmin_flt, cpu, cstime, cutime, eip, end_code, esp, exit_signal, flags, input, it_real_value, maj_flt, min_flt, nicev, NULL, num_threads, obuf, pending, pgid, pid, policy, ppid, printchar(), printone(), printonex(), printstr(), printtime(), printtimediff(), priority, readchar(), readone(), readstr(), readunsigned(), rss, rsslim, rt_priority, sid, sigcatch, sigign, start_code, start_stack, start_time, stimev, tcomm, tickspersec, tty_nr, tty_pgrp, utime, vsize, wchan, zero1, and zero2.

                                         {
      tickspersec = sysconf(_SC_CLK_TCK);
      input = NULL;
      
      std::ostringstream ost; 
      ost << "/proc/" << getpid() << "/stat";
      input = fopen(ost.str().c_str(), "r");
      

      readone(&pid);
      readstr(tcomm);
      readchar(&state);
      readone(&ppid);
      readone(&pgid);
      readone(&sid);
      readone(&tty_nr);
      readone(&tty_pgrp);
      readone(&flags);
      readone(&min_flt);
      readone(&cmin_flt);
      readone(&maj_flt);
      readone(&cmaj_flt);
      readone(&utime);
      readone(&stimev);
      readone(&cutime);
      readone(&cstime);
      readone(&priority);
      readone(&nicev);
      readone(&num_threads);
      readone(&it_real_value);
      readunsigned(&start_time);
      readone(&vsize);
      readone(&rss);
      readone(&rsslim);
      readone(&start_code);
      readone(&end_code);
      readone(&start_stack);
      readone(&esp);
      readone(&eip);
      readone(&pending);
      readone(&blocked);
      readone(&sigign);
      readone(&sigcatch);
      readone(&wchan);
      readone(&zero1);
      readone(&zero2);
      readone(&exit_signal);
      readone(&cpu);
      readone(&rt_priority);
      readone(&policy);
      
      {
        printone("pid", pid); *out << obuf;
        printstr("tcomm", tcomm); *out << obuf;
        printchar("state", state); *out << obuf;
        printone("ppid", ppid); *out << obuf;
        printone("pgid", pgid); *out << obuf;
        printone("sid", sid); *out << obuf;
        printone("tty_nr", tty_nr); *out << obuf;
        printone("tty_pgrp", tty_pgrp); *out << obuf;
        printone("flags", flags); *out << obuf;
        printone("min_flt", min_flt); *out << obuf;
        printone("cmin_flt", cmin_flt); *out << obuf;
        printone("maj_flt", maj_flt); *out << obuf;
        printone("cmaj_flt", cmaj_flt); *out << obuf;
        printtime("utime", utime); *out << obuf;
        printtime("stime", stimev); *out << obuf;
        printtime("cutime", cutime); *out << obuf;
        printtime("cstime", cstime); *out << obuf;
        printone("priority", priority); *out << obuf;
        printone("nice", nicev); *out << obuf;
        printone("num_threads", num_threads); *out << obuf;
        printtime("it_real_value", it_real_value); *out << obuf;
        printtimediff("start_time", start_time); *out << obuf;
        printone("vsize", vsize); *out << obuf;
        printone("rss", rss); *out << obuf;
        printone("rsslim", rsslim); *out << obuf;
        printone("start_code", start_code); *out << obuf;
        printone("end_code", end_code); *out << obuf;
        printone("start_stack", start_stack); *out << obuf;
        printone("esp", esp); *out << obuf;
        printone("eip", eip); *out << obuf;
        printonex("pending", pending); *out << obuf;
        printonex("blocked", blocked); *out << obuf;
        printonex("sigign", sigign); *out << obuf;
        printonex("sigcatch", sigcatch); *out << obuf;
        printone("wchan", wchan); *out << obuf;
        printone("zero1", zero1); *out << obuf;
        printone("zero2", zero2); *out << obuf;
        printonex("exit_signal", exit_signal); *out << obuf;
        printone("cpu", cpu); *out << obuf;
        printone("rt_priority", rt_priority); *out << obuf;
        printone("policy", policy); *out << obuf;
      }
      fclose(input);
    }
void evf::utils::readchar ( char *  x)

Definition at line 128 of file procUtils.cc.

References input.

Referenced by procStat().

{  fscanf(input, "%c ", x);}
void evf::utils::readone ( num *  x)

Definition at line 125 of file procUtils.cc.

References input.

Referenced by procCpuStat(), and procStat().

{ fscanf(input, "%lld ", x); }
void evf::utils::readstr ( char *  x)

Definition at line 127 of file procUtils.cc.

References input.

Referenced by procCpuStat(), and procStat().

{  fscanf(input, "%s ", x);}
void evf::utils::readunsigned ( unsigned long long *  x)

Definition at line 126 of file procUtils.cc.

References input.

Referenced by procStat().

{ fscanf(input, "%llu ", x); }
void evf::utils::uptime ( std::ostringstream *  out)

Definition at line 309 of file procUtils.cc.

References LOAD_FRAC, LOAD_INT, and cond::rpcobgas::time.

Referenced by evf::FUEventProcessor::updater().

    {
#ifdef linux
      int updays, uphours, upminutes;
      struct sysinfo info;
      struct tm *current_time;
      time_t current_secs;

      time(&current_secs);
      current_time = localtime(&current_secs);

      sysinfo(&info);

      *out << std::setw(2) 
           << (current_time->tm_hour%12 ? current_time->tm_hour%12 : 12)
           << ":"
           << current_time->tm_min
           << (current_time->tm_hour > 11 ? " pm, " : " am, ")
           << " up ";
      updays = (int) info.uptime / (60*60*24);
      if (updays)
        *out <<  updays << " day" << ((updays != 1) ? "s " : " ");
      upminutes = (int) info.uptime / 60;
      uphours = (upminutes / 60) % 24;
      upminutes %= 60;
      if(uphours)
        *out << std::setw(2) << uphours << ":" << upminutes;
      else
        *out << upminutes << " minutes ";
      
      *out << " - load average "
           << LOAD_INT(info.loads[0]) << " " 
           << LOAD_FRAC(info.loads[0]) << " " 
           << LOAD_INT(info.loads[1]) << " " 
           << LOAD_FRAC(info.loads[1]) << " " 
           << LOAD_INT(info.loads[2]) << " " 
           << LOAD_FRAC(info.loads[2]) << " ";
      *out << " used memory " << std::setw(3) 
           << (float(info.totalram-info.freeram)/float(info.totalram))*100 << "%";
#else
      // FIXME: one could probably use `clock_get_uptime` and similar on 
      // macosx to obtain at least part of the information.
      *out << "Unable to retrieve uptime information on this platform.";
#endif
    }

Variable Documentation

Definition at line 110 of file procUtils.cc.

Referenced by FWEveViewManager::highlightAdded(), and procStat().

Definition at line 87 of file procUtils.cc.

Referenced by procStat().

Definition at line 85 of file procUtils.cc.

Referenced by procStat().

Definition at line 117 of file procUtils.cc.

Referenced by procCpuStat(), procStat(), and TimeMe::TimeMe().

Definition at line 92 of file procUtils.cc.

Referenced by procStat().

Definition at line 91 of file procUtils.cc.

Referenced by procStat().

Definition at line 107 of file procUtils.cc.

Referenced by procStat(), and stacktrace().

Definition at line 104 of file procUtils.cc.

Referenced by procStat().

Definition at line 106 of file procUtils.cc.

Referenced by procStat(), and stacktrace().

Definition at line 116 of file procUtils.cc.

Referenced by procStat().

Definition at line 83 of file procUtils.cc.

Referenced by procStat().

Definition at line 123 of file procUtils.cc.

Referenced by procCpuStat(), procStat(), readchar(), readone(), readstr(), and readunsigned().

Definition at line 96 of file procUtils.cc.

Referenced by procStat().

Definition at line 86 of file procUtils.cc.

Referenced by procStat().

Definition at line 84 of file procUtils.cc.

Referenced by procStat().

Definition at line 94 of file procUtils.cc.

Referenced by procStat().

Definition at line 95 of file procUtils.cc.

Referenced by procStat().

char evf::utils::obuf[4096]

Definition at line 109 of file procUtils.cc.

Referenced by procStat().

Definition at line 78 of file procUtils.cc.

Referenced by procStat().

Definition at line 73 of file procUtils.cc.

Referenced by evf::Vulture::analyze(), SiPixelErrorEstimation::analyze(), SiPixelTrackingRecHitsValid::analyze(), Rivet::CMS_2011_S8978280::analyze(), evf::FUResourceBroker::customWebPage(), SiStripCommissioningSource::directory(), CalibrationScanTask::directory(), CalibrationTask::directory(), ChargeDividerFP420::divide(), evf::rb_statemachine::Stopping::emergencyStop(), ExternalLHEProducer::executeScript(), TriggerSummaryProducerAOD::fillFilterObjectMembers(), QcdLowPtDQM::fillPixels(), TriggerSummaryProducerAOD::fillTriggerObjectCollections(), PythiaFilterEMJetHeep::filter(), PythiaFilterGammaJetIsoPi0::filter(), PythiaFilterGammaJet::filter(), PythiaFilterGammaJetWithOutBg::filter(), PythiaFilterGammaJetWithBg::filter(), HighMultiplicityGenFilter::filter(), TauValidation::findTauDecayChannel(), RemoteFile::get(), HitInfo::getInfo(), TrajectoryCleanerMerger::getLayer(), ValidHitPairFilter::getLayer(), TrackClassifier::hadronFlavor(), HLTDoubletDZ< T1, T2 >::hltFilter(), HLTDoublet< T1, T2 >::hltFilter(), TauValidation::leadingPionP4(), TrackHistoryAnalyzer::particleString(), VertexHistoryAnalyzer::particleString(), TauValidation::photons(), edm::service::SimpleProfiling::postEndJob(), SiPixelDigitizerAlgorithm::primary_ionization(), HepMCFileReader::printEvent(), procStat(), PixelVertexProducerClusters::produce(), L3MuonCandidateProducer::produce(), L2MuonCandidateProducer::produce(), L3MuonCandidateProducerFromMuons::produce(), MuonSimHitProducer::produce(), CSCCathodeLCTProcessor::ptnFinding(), CaloMeanResponse::readResponse(), CalorimetryManager::reconstruct(), CalorimetryManager::reconstructHCAL(), run_script(), edm::Provenance::setProductID(), evf::FUResourceTable::shutDownClients(), TauValidation::spinEffectsZ(), evf::FWEPWrapper::startMonitoringWorkLoop(), evf::FUEventProcessor::subWeb(), TauValidation::tauProngs(), HcalTB04Analysis::update(), HcalTB06Analysis::update(), ValidHitPairFilter::ValidHitPairFilter(), TrackHistoryAnalyzer::vertexString(), VertexHistoryAnalyzer::vertexString(), TauValidation::visibleTauEnergy(), and evf::rb_statemachine::SharedResources::watching().

Definition at line 77 of file procUtils.cc.

Referenced by procStat().

Definition at line 93 of file procUtils.cc.

Referenced by procStat().

Definition at line 101 of file procUtils.cc.

Referenced by procStat(), and edm::service::SimpleMemoryCheck::updateEventStats().

Definition at line 102 of file procUtils.cc.

Referenced by procStat().

Definition at line 118 of file procUtils.cc.

Referenced by procStat().

Definition at line 112 of file procUtils.cc.

Referenced by procStat().

Definition at line 111 of file procUtils.cc.

Referenced by procStat().

Definition at line 103 of file procUtils.cc.

Referenced by procStat().

Definition at line 105 of file procUtils.cc.

Referenced by procStat().

unsigned long long evf::utils::start_time

Definition at line 98 of file procUtils.cc.

Referenced by ecaldqm::calcBins(), and procStat().

Definition at line 75 of file procUtils.cc.

Referenced by MuonErrorMatrix::adjust(), edm::service::RandomNumberGeneratorService::backwardCompatibilityRead(), edm::EventSelector::containsExceptions(), NavVolume6Faces::crossToNextVolume(), debug_config_state_machine(), debug_state_machine(), DisplayManager::enableDrawBrem(), DisplayManager::enableDrawPFBlock(), AlignmentMonitorTracksFromTrajectories::event(), SiStripElectronAlgo::findElectron(), GaussianSumUtilities1D::findMode(), reco::GhostTrackFitter::fit(), reco::PositiveSideGhostTrackFitter::fit(), reco::SequentialGhostTrackFitter::fit(), KinematicParticleVertexFitter::fit(), evf::iDie::fsmCallback(), cscdqm::Summary::GetValue(), reco::GhostTrackVertexFinder::initialVertices(), reco::GhostTrack::initStates(), reco::modules::CosmicTrackSplitter::makeCandidate(), reco::modules::TrackerTrackHitFilter::makeCandidate(), edm::EventSelector::maskTriggerResults(), BasicGenParticleValidation::matchParticles(), reco::GhostTrackVertexFinder::mergeVertices(), TSGForRoadSearch::notAtIPtsos(), reco::AnnealingGhostTrackFitter::postFit(), RoadSearchTrackCandidateMakerAlgorithm::PrepareTrackCandidates(), L2MuonSeedGenerator::produce(), cms::CosmicTrackFinder::produce(), cms::CkfTrackCandidateMakerBase::produceBase(), cms::HITrackVertexMaker::produceTracks(), CachedTrajectory::propagate(), evf::FUShmBuffer::setDqmState(), evf::FUShmBuffer::setEvtState(), edm::StreamerOutputModuleBase::setHltMask(), edm::RandomEngineStates::setRandomEngineStates(), FWMagField::setReverseState(), CachedTrajectory::setStateAtIP(), edm::service::RandomNumberGeneratorService::snapShot(), InOutConversionTrackFinder::tracks(), OutInConversionTrackFinder::tracks(), TrimmedVertexFitter::vertex(), SequentialVertexFitter< N >::vertex(), reco::GhostTrackVertexFinder::vertices(), and Overlayer::ylabel().

Definition at line 89 of file procUtils.cc.

Referenced by procStat().

char evf::utils::tcomm[FILENAME_MAX]

Definition at line 74 of file procUtils.cc.

Referenced by procStat().

Definition at line 121 of file procUtils.cc.

Referenced by gettimesinceboot(), printtime(), printtimediff(), and procStat().

Definition at line 80 of file procUtils.cc.

Referenced by procStat().

Definition at line 81 of file procUtils.cc.

Referenced by procStat().

Definition at line 88 of file procUtils.cc.

Referenced by procStat(), and RPCFw::TtoUT().

Definition at line 113 of file procUtils.cc.

Referenced by procStat().

Definition at line 114 of file procUtils.cc.

Referenced by procStat().

Definition at line 115 of file procUtils.cc.

Referenced by procStat().