CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/Utilities/Timing/src/PentiumTimer.cc

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