STL_perf_analyzer.hh
Go to the documentation of this file.
00001 //=====================================================
00002 // File   :  STL_perf_analyzer.hh
00003 // Author :  L. Plagne <laurent.plagne@edf.fr)>        
00004 // Copyright (C) EDF R&D,  mar déc 3 18:59:35 CET 2002
00005 //=====================================================
00006 // 
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 // 
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 // 
00020 #ifndef _STL_PERF_ANALYSER_HH
00021 #define _STL_PERF_ANALYSER_HH
00022 
00023 #include "STL_timer.hh"
00024 #include "bench_parameter.hh"
00025 
00026 template<class ACTION>
00027 class STL_Perf_Analyzer{
00028 public:  
00029   STL_Perf_Analyzer(unsigned long long nb_sample=DEFAULT_NB_SAMPLE):_nb_sample(nb_sample),_chronos()
00030   {
00031     MESSAGE("STL_Perf_Analyzer Ctor");
00032   }; 
00033   STL_Perf_Analyzer( const STL_Perf_Analyzer & ){
00034     INFOS("Copy Ctor not implemented");
00035     exit(0);
00036   };
00037   ~STL_Perf_Analyzer( void ){
00038     MESSAGE("STL_Perf_Analyzer Dtor");
00039   };
00040   
00041   
00042   inline double eval_mflops(int size)
00043   {
00044 
00045     ACTION action(size);
00046 
00047     _chronos.start_baseline(_nb_sample);
00048       
00049     do {
00050 
00051       action.initialize();
00052     } while (_chronos.check());
00053 
00054     double baseline_time=_chronos.get_time();
00055 
00056     _chronos.start(_nb_sample);
00057     do {
00058       action.initialize();
00059       action.calculate();
00060     } while (_chronos.check());
00061 
00062     double calculate_time=_chronos.get_time();
00063 
00064     double corrected_time=calculate_time-baseline_time;
00065     
00066     //    cout << size <<" "<<baseline_time<<" "<<calculate_time<<" "<<corrected_time<<" "<<action.nb_op_base() << endl;    
00067     
00068     return action.nb_op_base()/(corrected_time*1000000.0);
00069     //return action.nb_op_base()/(calculate_time*1000000.0);
00070     
00071   }
00072 private:
00073 
00074   STL_Timer _chronos;
00075   unsigned long long _nb_sample;
00076 
00077   
00078 };
00079 
00080   
00081   
00082 #endif


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:33:00