From b4dd5d592c0d32debb8d0c784e71d977e3d1e1f2 Mon Sep 17 00:00:00 2001 From: fpaparel Date: Wed, 13 Sep 2006 11:26:03 +0000 Subject: [PATCH] - 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 --- src/backend/concrete_simulation_statistics.cc | 108 ++++++++++++++---- src/backend/concrete_simulation_statistics.hh | 10 +- src/backend/concrete_thread_statistics.cc | 4 +- src/backend/sgpemv2/simulation_statistics.hh | 5 +- src/schedulables_statistics_widget.cc | 13 +++ .../environments/pensieri.xgp | 46 ++++++++ 6 files changed, 160 insertions(+), 26 deletions(-) create mode 100644 src/testsuite/scheduling-wizards/environments/pensieri.xgp diff --git a/src/backend/concrete_simulation_statistics.cc b/src/backend/concrete_simulation_statistics.cc index a4fe7d4..76fc620 100644 --- a/src/backend/concrete_simulation_statistics.cc +++ b/src/backend/concrete_simulation_statistics.cc @@ -20,8 +20,12 @@ #include "concrete_simulation_statistics.hh" #include +#include +#include +#include #include +#include using namespace std; using namespace sgpem; @@ -30,35 +34,86 @@ ConcreteSimulationStatistics::~ConcreteSimulationStatistics() { } -ConcreteSimulationStatistics::ConcreteSimulationStatistics(const std::vector proc_stats, const int& instant) +ConcreteSimulationStatistics::ConcreteSimulationStatistics(const std::vector& 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 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 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::const_iterator p; for (p = proc_stats.begin(); p != proc_stats.end(); p++) { - schedulables_count++; - _average_response_time += p->get_response_time(); - /* - vector 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 thread_stats = p->get_threads_statistics(); + vector::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; } - diff --git a/src/backend/concrete_simulation_statistics.hh b/src/backend/concrete_simulation_statistics.hh index dc57798..be4c674 100644 --- a/src/backend/concrete_simulation_statistics.hh +++ b/src/backend/concrete_simulation_statistics.hh @@ -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 proc_stats, const int& instant); + ConcreteSimulationStatistics(const std::vector& 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 ; }; } diff --git a/src/backend/concrete_thread_statistics.cc b/src/backend/concrete_thread_statistics.cc index b7e484c..b3923ab 100644 --- a/src/backend/concrete_thread_statistics.cc +++ b/src/backend/concrete_thread_statistics.cc @@ -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 diff --git a/src/backend/sgpemv2/simulation_statistics.hh b/src/backend/sgpemv2/simulation_statistics.hh index f9c3a50..d2fabb4 100644 --- a/src/backend/sgpemv2/simulation_statistics.hh +++ b/src/backend/sgpemv2/simulation_statistics.hh @@ -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: diff --git a/src/schedulables_statistics_widget.cc b/src/schedulables_statistics_widget.cc index 46f90ef..a0c0145 100644 --- a/src/schedulables_statistics_widget.cc +++ b/src/schedulables_statistics_widget.cc @@ -30,6 +30,8 @@ #include #include +#include + 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"; } diff --git a/src/testsuite/scheduling-wizards/environments/pensieri.xgp b/src/testsuite/scheduling-wizards/environments/pensieri.xgp new file mode 100644 index 0000000..a7a7ec7 --- /dev/null +++ b/src/testsuite/scheduling-wizards/environments/pensieri.xgp @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +