- Finished backend SimulationStatistics, temporary stdout printout,

added pensieri.xgp to show fcfs problem



git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1125 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
fpaparel 2006-09-13 11:26:03 +00:00
parent 2c9c5ec498
commit b4dd5d592c
6 changed files with 160 additions and 26 deletions

View file

@ -20,8 +20,12 @@
#include "concrete_simulation_statistics.hh"
#include <sgpemv2/statistics.hh>
#include <sgpemv2/simulation.hh>
#include <sgpemv2/history.hh>
#include <sgpemv2/environment.hh>
#include <iostream>
#include <math.h>
using namespace std;
using namespace sgpem;
@ -30,35 +34,86 @@ ConcreteSimulationStatistics::~ConcreteSimulationStatistics()
{
}
ConcreteSimulationStatistics::ConcreteSimulationStatistics(const std::vector<ConcreteProcessStatistics> proc_stats, const int& instant)
ConcreteSimulationStatistics::ConcreteSimulationStatistics(const std::vector<ConcreteProcessStatistics>& proc_stats, const int& instant)
{
_average_inactivity_time = 0;
_average_turn_around = 0;
_average_response_time = 0;
_average_efficiency = 0;
_terminated_processes = 0;
_terminated_threads = 0;
_average_throughput = 0;
_average_inactivity_time = 0;
_average_turn_around = 0;
_average_response_time = 0;
_average_efficiency = 0;
_terminated_processes = 0;
_terminated_threads = 0;
_average_execution_progress = 0 ;
_average_processes_throughput = 0;
_average_threads_throughput = 0;
int schedulables_count = 0;
int started_schedulables_count = 0; //useful for stats thath can be -1
if (instant == -1)
return;
//get infos that don't depend on the Processes statistics
//but on the current environment:
//iterate through all processes
vector<Process*> procs = Simulation::get_instance().get_history().get_environment_at(instant).get_processes();
for (uint i=0; i < procs.size(); i++)
{
if (procs[i]->get_state() == Schedulable::state_terminated)
_terminated_processes++;
vector<Thread*> threads = procs[i]->get_threads();
//iterate through all threads of this process
for (uint ii=0; ii < threads.size(); ii++)
if (threads[ii]->get_state() == Schedulable::state_terminated)
_terminated_threads++;
}
//Examinate processes and threads statistics:
//SUM all values from processes and threads
vector<ConcreteProcessStatistics>::const_iterator p;
for (p = proc_stats.begin(); p != proc_stats.end(); p++)
{
schedulables_count++;
_average_response_time += p->get_response_time();
/*
vector<ThreadStatistics> Tstats = Pstats.get_threads_statistics();
for (uint t=0; t < Tstats.size(); t++)
if (p->get_response_time() != -1)
{
schedulables_count++;
_average_response_time += Tstats[t].get_response_time();
started_schedulables_count++;
_average_response_time += p->get_response_time();
_average_efficiency += p->get_efficiency();
_average_inactivity_time += p->get_total_inactivity();
_average_turn_around += p->get_turn_around();
_average_execution_progress += p->get_execution_progress();
}
*/
//iterate through all threads of this process
vector<const ThreadStatistics*> thread_stats = p->get_threads_statistics();
vector<const ThreadStatistics*>::const_iterator t;
for (t=thread_stats.begin(); t != thread_stats.end(); t++)
if ((*t)->get_response_time() != -1)
{
started_schedulables_count++;
_average_response_time += (*t)->get_response_time();
_average_efficiency += (*t)->get_efficiency();
_average_inactivity_time += (*t)->get_total_inactivity();
_average_turn_around += (*t)->get_turn_around();
_average_execution_progress += (*t)->get_execution_progress();
}
}
//make the AVARAGE and ROUND the values
if (started_schedulables_count != 0)
{
_average_response_time = roundf((_average_response_time/started_schedulables_count)*100)/100.0;
_average_efficiency = roundf((_average_efficiency/started_schedulables_count)*100)/100.0;
_average_inactivity_time = roundf((_average_inactivity_time/started_schedulables_count)*100)/100.0;
_average_turn_around = roundf((_average_turn_around/started_schedulables_count)*100)/100.0;
_average_execution_progress = roundf((_average_execution_progress/started_schedulables_count)*100)/100.0;
}
if (instant != 0)
{
_average_processes_throughput = roundf(((float)_terminated_processes/(float)instant)*1000)/1000.0;
_average_threads_throughput = roundf(((float)_terminated_threads /(float)instant)*1000)/1000.0;
}
}
@ -70,6 +125,12 @@ ConcreteSimulationStatistics::get_average_inactivity_time() const
return _average_inactivity_time;
}
float
ConcreteSimulationStatistics::get_average_execution_progress() const
{
return _average_execution_progress;
}
float
ConcreteSimulationStatistics::get_average_turn_around() const
{
@ -101,10 +162,15 @@ ConcreteSimulationStatistics::get_terminated_threads() const
}
float
ConcreteSimulationStatistics::get_average_throughput() const
ConcreteSimulationStatistics::get_average_processes_throughput() const
{
return _average_throughput;
return _average_processes_throughput;
}
float
ConcreteSimulationStatistics::get_average_threads_throughput() const
{
return _average_threads_throughput;
}

View file

@ -39,23 +39,27 @@ namespace sgpem
~ConcreteSimulationStatistics();
float get_average_inactivity_time() const ;
float get_average_execution_progress() const;
float get_average_turn_around() const ;
float get_average_response_time() const ;
float get_average_efficiency() const ;
int get_terminated_processes() const ;
int get_terminated_threads() const ;
float get_average_throughput() const ;
float get_average_processes_throughput() const ;
float get_average_threads_throughput() const ;
protected:
ConcreteSimulationStatistics(const std::vector<ConcreteProcessStatistics> proc_stats, const int& instant);
ConcreteSimulationStatistics(const std::vector<ConcreteProcessStatistics>& proc_stats, const int& instant);
float _average_inactivity_time ;
float _average_execution_progress ;
float _average_turn_around ;
float _average_response_time ;
float _average_efficiency ;
int _terminated_processes ;
int _terminated_threads ;
float _average_throughput ;
float _average_processes_throughput ;
float _average_threads_throughput ;
};
}

View file

@ -120,7 +120,9 @@ ConcreteThreadStatistics::ConcreteThreadStatistics(const Thread* core, const int
}//istants
//set other variables
_execution_progress = (100*_execution_time)/core->get_total_cpu_time();
if (core->get_total_cpu_time() != 0)
_execution_progress = (100*_execution_time)/core->get_total_cpu_time();
if (_turn_around == 0)
_efficiency = -1;
else

View file

@ -32,12 +32,15 @@ namespace sgpem
virtual ~SimulationStatistics();
virtual float get_average_inactivity_time() const =0;
virtual float get_average_execution_progress() const =0;
virtual float get_average_turn_around() const =0;
virtual float get_average_response_time() const =0;
virtual float get_average_efficiency() const =0;
virtual int get_terminated_processes() const =0;
virtual int get_terminated_threads() const =0;
virtual float get_average_throughput() const =0;
virtual float get_average_processes_throughput() const =0;
virtual float get_average_threads_throughput() const =0;
protected: