CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/FWCore/Services/src/SimpleProfiler.h

Go to the documentation of this file.
00001 #ifndef FWCore_Services_SimpleProfiler_h
00002 #define FWCore_Services_SimpleProfiler_h
00003 
00004 #ifndef _POSIX_C_SOURCE
00005 #define _POSIX_C_SOURCE 199309
00006 #endif
00007 
00008 #include <vector>
00009 #include <string>
00010 #include "boost/thread/mutex.hpp"
00011 
00012 class SimpleProfiler
00013 {
00014  public:
00015   typedef std::vector<void*> VoidVec;
00016   typedef VoidVec::size_type size_type;
00017 
00018   static SimpleProfiler* instance();
00019 
00020   void start();
00021   void stop();
00022 
00023   void* stackTop() { return stacktop_; }
00024   void** tempStack() { return &tmp_stack_[0]; }
00025   size_type tempStackSize() { return tmp_stack_.size(); }
00026   
00027   void commitFrame(void** first, void** last);
00028 
00029  private:
00030   SimpleProfiler();
00031   ~SimpleProfiler();
00032 
00033   void complete();
00034   void doWrite();
00035 
00036   static SimpleProfiler* inst_;
00037   static boost::mutex lock_;
00038   VoidVec frame_data_;
00039   VoidVec tmp_stack_;
00040   void** high_water_;
00041   void** curr_;
00042   std::string filename_;
00043   int fd_;
00044   bool installed_;
00045   bool running_;
00046   pthread_t owner_;
00047   void* stacktop_;
00048 };
00049 
00050 #endif