- 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:

View File

@ -30,6 +30,8 @@
#include <iostream>
#include <sstream>
#include <sgpemv2/simulation_statistics.hh>
using namespace sgpem;
using namespace std;
@ -134,6 +136,17 @@ TabularSchedulableStatisticsWidget::update(const History& changed_history)
}
}
expand_all();
const SimulationStatistics* sim = Statistics::get_instance().get_simulation_statistics();
cout << "\n\n****** SIMULATION STATISTICS *******\n AVG_RESP= "
<< sim->get_average_response_time() << " AVG_INACT= " << sim->get_average_inactivity_time() <<
" AVG_EXEC= " << sim->get_average_execution_progress() <<
"% AVG_EFFIC= " << sim->get_average_efficiency() <<
"% AVG_TURN= " << sim->get_average_turn_around() <<
" TERM_PROCS= " << sim->get_terminated_processes() <<
" TERM_THRES= " << sim->get_terminated_threads() <<
" THRU_PROCS= " << sim->get_average_processes_throughput() <<
" THRU_THREA= " << sim->get_average_threads_throughput() << "\n\n";
}

View File

@ -0,0 +1,46 @@
<?xml version="1.0"?>
<!DOCTYPE sgpem SYSTEM "sgpem.dtd">
<sgpem>
<resources/>
<schedulables>
<process name="Edifici" priority="0" arrival-time="0">
<threads>
<thread name="casa" priority="0" arrival-delta="0" lasts-for="5">
<requests/>
</thread>
<thread name="palazzo" priority="1" arrival-delta="2" lasts-for="3">
<requests/>
</thread>
</threads>
</process>
<process name="Attila" priority="0" arrival-time="1">
<threads>
<thread name="atrocit&#xE0;" priority="3" arrival-delta="0" lasts-for="2">
<requests/>
</thread>
<thread name="terrremoto e tragggedia" priority="0" arrival-delta="1" lasts-for="6">
<requests/>
</thread>
<thread name="irrdiddio" priority="5" arrival-delta="1" lasts-for="1">
<requests/>
</thread>
<thread name="lago di sangue" priority="0" arrival-delta="0" lasts-for="3">
<requests/>
</thread>
<thread name="adesso vengo e ti sfascio le corna" priority="0" arrival-delta="5" lasts-for="2">
<requests/>
</thread>
</threads>
</process>
<process name="Desideri" priority="0" arrival-time="0">
<threads>
<thread name="mangiare" priority="0" arrival-delta="0" lasts-for="3">
<requests/>
</thread>
<thread name="bere" priority="0" arrival-delta="18" lasts-for="2">
<requests/>
</thread>
</threads>
</process>
</schedulables>
</sgpem>