// src/backend/concrete_statistics.cc - Copyright 2005, 2006, University // of Padova, dept. of Pure and Applied // Mathematics // // This file is part of SGPEMv2. // // This is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // SGPEMv2 is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with SGPEMv2; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "concrete_statistics.hh" #include #include #include #include #include #include #include "concrete_thread_statistics.hh" #include "concrete_process_statistics.hh" #include using namespace sgpem; using namespace std; ConcreteStatistics::ConcreteStatistics(): _sim_stats(0) { calculateStatisticsAt(-1); } void ConcreteStatistics::calculateStatisticsAt(const int& instant) { //retrieve all processes vector procs = Simulation::get_instance().get_history().get_environment_at(0).get_processes(); //create all process statistics (which themselves create their thread statistics) _proc_stats.clear(); for (unsigned int p = 0; p < procs.size(); p++) _proc_stats.push_back(ConcreteProcessStatistics(procs[p], instant)); if (_sim_stats) delete _sim_stats; //create simulation statistics using just obtained process statistics _sim_stats = new ConcreteSimulationStatistics(_proc_stats, instant); } const SimulationStatistics* ConcreteStatistics::get_simulation_statistics() const { return _sim_stats; } /** \warning Don't delete these pointers!! \warning These pointers are not valid anymore AFTER a call to calculateStatisticsAt */ std::vector ConcreteStatistics::get_process_statistics() const { vector rit; for (unsigned int i=0; i < _proc_stats.size(); i++) rit.push_back(&_proc_stats[i]); return rit; }