Hybrid Query Processing Engine for Coprocessing in Database Systems
HyPE
|
00001 00002 00003 #include <core/loadchange_estimator.hpp> 00004 00005 using namespace std; 00006 00007 namespace hype{ 00008 namespace core{ 00009 00010 LoadChangeEstimator::LoadChangeEstimator(unsigned int size_of_circular_buffer) : last_load_factors_() { 00011 last_load_factors_.set_capacity(size_of_circular_buffer); 00012 } 00013 00014 double LoadChangeEstimator::getLoadModificator() const throw(){ 00015 if(last_load_factors_.empty()){ 00016 return 1.0; 00017 }else{ 00018 //cout << "Load Factors" << endl; 00019 boost::circular_buffer<double>::const_iterator it; 00020 double sum=0; 00021 for(it=last_load_factors_.begin();it!=last_load_factors_.end();++it){ 00022 sum+=*it; 00023 //cout << "DEBUG: Load Factor: " << *it << endl; 00024 } 00025 //cout << "DEBUG: Result: " << sum/last_load_factors_.size() << endl; 00026 return sum/last_load_factors_.size(); //return average of last_load_factors_ 00027 } 00028 } 00029 00030 void LoadChangeEstimator::add(const MeasurementPair& mp) throw(){ 00031 last_load_factors_.push_back(mp.getMeasuredTime().getTimeinNanoseconds()/mp.getEstimatedTime().getTimeinNanoseconds()); 00032 } 00033 00034 }; //end namespace core 00035 }; //end namespace hype