CMS 3D CMS Logo

PentiumTimer.cc

Go to the documentation of this file.
00001 #ifdef __linux__
00002 
00003 #include "Utilities/Timing/interface/PentiumTimer.h"
00004 #include <iostream>
00005 #include <fstream>
00006 #include <string>
00007 #include <algorithm>
00008 #include <iterator>
00009 
00010 
00011 PentiumTime::OneTick::~OneTick(){}
00012 
00013 PentiumTime::OneTick::OneTick() {
00014   
00015   std::string input; 
00016   {
00017     std::ifstream cpuinfo("/proc/cpuinfo");
00018     cpuinfo.unsetf( std::ios::skipws );
00019     std::istream_iterator<char> sbegin(cpuinfo),send;
00020     copy(sbegin,send,inserter(input,input.end()));
00021     cpuinfo.close();
00022   }
00023   size_t i = input.find("cpu MHz");
00024   if (i==std::string::npos) {
00025     std::cout << "/proc/cpuinfo does not contain cpu speed..." << std::endl;
00026     one = 1.;
00027     return;
00028   }
00029   i = input.find(":",i);  
00030   one = 1.e-6/atof(input.substr(i+1,input.find("/n",i)-i).c_str());
00031 }
00032 #endif

Generated on Tue Jun 9 17:48:58 2009 for CMSSW by  doxygen 1.5.4