sgpemv2/src/backend/concrete_statistics.cc
elvez 6d54f886f1 - Fixed portability issues. I'm curious to know where that programmer learnt about 'roundf' and 'uint', anyway...
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1153 3ecf2c5c-341e-0410-92b4-d18e462d057c
2006-09-14 17:42:15 +00:00

80 lines
2.4 KiB
C++

// 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 <sgpemv2/simulation.hh>
#include <sgpemv2/history.hh>
#include <sgpemv2/environment.hh>
#include <sgpemv2/schedulable.hh>
#include <sgpemv2/process.hh>
#include <sgpemv2/thread.hh>
#include "concrete_thread_statistics.hh"
#include "concrete_process_statistics.hh"
#include <iostream>
using namespace sgpem;
using namespace std;
ConcreteStatistics::ConcreteStatistics(): _sim_stats(0)
{
calculateStatisticsAt(-1);
}
void
ConcreteStatistics::calculateStatisticsAt(const int& instant)
{
//retrieve all processes
vector<Process*> 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<const ProcessStatistics*>
ConcreteStatistics::get_process_statistics() const
{
vector<const ProcessStatistics*> rit;
for (unsigned int i=0; i < _proc_stats.size(); i++)
rit.push_back(&_proc_stats[i]);
return rit;
}