- Adeed simple tabular statistics, modified statistics interfaces,
updated architecture (don't know if something is missing...) git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1092 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
afd292142e
commit
96dbda64cd
23
Makefile.am
23
Makefile.am
|
@ -161,8 +161,11 @@ src_backend_libbackend_la_LIBADD = \
|
|||
src_backend_libbackend_la_SOURCES = \
|
||||
src/backend/concrete_environment.cc \
|
||||
src/backend/concrete_history.cc \
|
||||
src/backend/concrete_process_statistics.cc \
|
||||
src/backend/concrete_simulation.cc \
|
||||
src/backend/concrete_simulation_statistics.cc \
|
||||
src/backend/concrete_statistics.cc \
|
||||
src/backend/concrete_thread_statistics.cc \
|
||||
src/backend/cpu_policies_gatekeeper.cc \
|
||||
src/backend/cpu_policy.cc \
|
||||
src/backend/cpu_policy_exception.cc \
|
||||
|
@ -206,6 +209,7 @@ src_backend_libbackend_la_SOURCES = \
|
|||
src/backend/serializers_gatekeeper.cc \
|
||||
src/backend/simulation.cc \
|
||||
src/backend/simulation_observer.cc \
|
||||
src/backend/simulation_statistics.cc \
|
||||
src/backend/static_process.cc \
|
||||
src/backend/static_request.cc \
|
||||
src/backend/static_resource.cc \
|
||||
|
@ -241,6 +245,7 @@ pkginclude_HEADERS += \
|
|||
src/backend/sgpemv2/policy_parameters.hh \
|
||||
src/backend/sgpemv2/plugin.hh \
|
||||
src/backend/sgpemv2/plugin_manager.hh \
|
||||
src/backend/sgpemv2/process_statistics.hh \
|
||||
src/backend/sgpemv2/ready_queue.hh \
|
||||
src/backend/sgpemv2/request.hh \
|
||||
src/backend/sgpemv2/resource.hh \
|
||||
|
@ -260,10 +265,12 @@ pkginclude_HEADERS += \
|
|||
src/backend/sgpemv2/serializers_gatekeeper.hh \
|
||||
src/backend/sgpemv2/simulation.hh \
|
||||
src/backend/sgpemv2/simulation_observer.hh \
|
||||
src/backend/sgpemv2/simulation_statistics.hh \
|
||||
src/backend/sgpemv2/statistics.hh \
|
||||
src/backend/sgpemv2/string_utils.hh \
|
||||
src/backend/sgpemv2/sub_request.hh \
|
||||
src/backend/sgpemv2/thread.hh \
|
||||
src/backend/sgpemv2/thread_statistics.hh \
|
||||
src/backend/sgpemv2/user_interrupt_exception.hh
|
||||
|
||||
|
||||
|
@ -272,22 +279,24 @@ pkginclude_HEADERS += \
|
|||
noinst_HEADERS += \
|
||||
src/backend/concrete_environment.hh \
|
||||
src/backend/concrete_history.hh \
|
||||
src/backend/concrete_process_statistics.hh \
|
||||
src/backend/concrete_simulation.hh \
|
||||
src/backend/concrete_simulation_statistics.hh \
|
||||
src/backend/concrete_statistics.hh \
|
||||
src/backend/concrete_thread_statistics.hh \
|
||||
src/backend/dynamic_process.hh \
|
||||
src/backend/dynamic_request.hh \
|
||||
src/backend/dynamic_resource.hh \
|
||||
src/backend/dynamic_schedulable.hh \
|
||||
src/backend/dynamic_sub_request.hh \
|
||||
src/backend/dynamic_thread.hh \
|
||||
src/backend/process_statistics.hh \
|
||||
src/backend/static_process.hh \
|
||||
src/backend/static_request.hh \
|
||||
src/backend/static_resource.hh \
|
||||
src/backend/static_schedulable.hh \
|
||||
src/backend/static_sub_request.hh \
|
||||
src/backend/static_thread.hh \
|
||||
src/backend/thread_statistics.hh
|
||||
src/backend/static_thread.hh
|
||||
|
||||
|
||||
|
||||
# ############################################################
|
||||
|
@ -334,9 +343,11 @@ sgpemv2_SOURCES = \
|
|||
src/ready_queue_widget.cc \
|
||||
src/resources_widget.cc \
|
||||
src/schedulable_state_widget.cc \
|
||||
src/schedulables_statistics_widget.cc \
|
||||
src/schedulables_tree_widget.cc \
|
||||
src/simulation_controller.cc \
|
||||
src/simulation_controller.cc \
|
||||
src/simulation_widget.cc \
|
||||
src/statistics_container_window.cc \
|
||||
src/text_simulation.cc
|
||||
|
||||
noinst_HEADERS += \
|
||||
|
@ -354,9 +365,11 @@ noinst_HEADERS += \
|
|||
src/ready_queue_widget.hh \
|
||||
src/resources_widget.hh \
|
||||
src/schedulable_state_widget.hh \
|
||||
src/schedulables_statistics_widget.hh \
|
||||
src/schedulables_tree_widget.hh \
|
||||
src/simulation_controller.hh \
|
||||
src/simulation_controller.hh \
|
||||
src/simulation_widget.hh \
|
||||
src/schedulables_statistics_widget.hh \
|
||||
src/text_simulation.hh
|
||||
|
||||
# ---------- glade files -----------
|
||||
|
|
|
@ -0,0 +1,207 @@
|
|||
// src/backend/concrete_process_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_process_statistics.hh"
|
||||
#include "concrete_thread_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 <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace sgpem;
|
||||
|
||||
/**
|
||||
The constructor executes all calculations examinating or only the Thred object,
|
||||
or the whole History
|
||||
|
||||
\param core The process whose statistics we are going to calculate
|
||||
\param instant The instant statistics will refer to
|
||||
\param _threads_stats The statistics of the threads belonging to "core"
|
||||
|
||||
*/
|
||||
ConcreteProcessStatistics::ConcreteProcessStatistics(const Process* core, const int& instant):
|
||||
_core(core)
|
||||
{
|
||||
//retrieve threads statistics necessary to calculate "core"'s statistics
|
||||
vector<const Thread*> threads = core->get_threads();
|
||||
for (uint i_t = 0; i_t < threads.size(); i_t++)
|
||||
_threads_stats.push_back(ConcreteThreadStatistics(threads[i_t], instant));
|
||||
|
||||
|
||||
//inizialize variables
|
||||
_total_inactivity = 0;
|
||||
_execution_time = 0;
|
||||
_response_time = -1;
|
||||
_turn_around = 0;
|
||||
_resource_usage_time = 0;
|
||||
_resource_waitings_time = 0;
|
||||
_average_response_time = 0;
|
||||
int min_reponse = -1; //useful for _response_time
|
||||
int arrived_threads = 0; //useful for _average_response_time
|
||||
bool someone_began = false; //useful for _response_time
|
||||
|
||||
//iterate through threads statistics
|
||||
vector<ConcreteThreadStatistics>::const_iterator i;
|
||||
for(i = _threads_stats.begin(); i != _threads_stats.end(); i++)
|
||||
{
|
||||
Thread* t = const_cast<Thread*>((*i).get_core());
|
||||
if (t->get_process() == *core)
|
||||
{ //found a thread belonging to "core"
|
||||
|
||||
_execution_time += (*i).get_execution_time();
|
||||
_resource_usage_time += (*i).get_resource_usage_time();
|
||||
|
||||
if ((*i).get_response_time() != -1)
|
||||
{
|
||||
_average_response_time += (*i).get_response_time();
|
||||
arrived_threads++;
|
||||
}
|
||||
|
||||
if ((*i).get_response_time() != -1 && someone_began == false)
|
||||
{
|
||||
someone_began = true;
|
||||
min_reponse = (*i).get_response_time();
|
||||
}
|
||||
|
||||
if(someone_began && (*i).get_response_time() != -1 && (*i).get_response_time() + (*i).get_real_arrival_time() < min_reponse)
|
||||
min_reponse = (*i).get_response_time() + (*i).get_real_arrival_time();
|
||||
|
||||
if ((*i).get_real_arrival_time() + (*i).get_execution_time() + (*i).get_total_inactivity() > _turn_around)
|
||||
_turn_around = (*i).get_real_arrival_time() + (*i).get_execution_time() + (*i).get_total_inactivity();
|
||||
}
|
||||
}
|
||||
|
||||
//******* AAARRRGGHH!!!
|
||||
//We have to iterate the whole History ONLY to retreive _resource_waitings_time !!
|
||||
//
|
||||
const History& hist = Simulation::get_instance().get_history();
|
||||
for (int time=0; time < instant; time++)
|
||||
{
|
||||
const Environment& env = hist.get_environment_at(time);
|
||||
const vector<Process*> procs = env.get_processes();
|
||||
|
||||
for (uint i_p=0; i_p < procs.size(); i_p++)
|
||||
if (*procs[i_p] == *core && procs[i_p]->get_state() == Schedulable::state_blocked)
|
||||
_resource_waitings_time++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//set other variables
|
||||
if(core->get_total_cpu_time() != 0)
|
||||
_execution_progress = (_execution_time*100) / core->get_total_cpu_time();
|
||||
else
|
||||
_execution_progress = 0;
|
||||
|
||||
_total_inactivity = _turn_around - _execution_time;
|
||||
|
||||
if (_turn_around == 0)
|
||||
_efficency = -1;
|
||||
else
|
||||
_efficency = (_execution_time*100)/_turn_around;
|
||||
|
||||
_response_time = min_reponse;
|
||||
|
||||
if (arrived_threads != 0)
|
||||
_average_response_time = (float)((int)((_average_response_time/arrived_threads)*100))/100;
|
||||
}
|
||||
|
||||
|
||||
ConcreteProcessStatistics::~ConcreteProcessStatistics()
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteProcessStatistics::get_execution_time() const
|
||||
{
|
||||
return _execution_time;
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteProcessStatistics::get_execution_progress() const
|
||||
{
|
||||
return _execution_progress;
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteProcessStatistics::get_total_inactivity() const
|
||||
{
|
||||
return _total_inactivity;
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteProcessStatistics::get_response_time() const
|
||||
{
|
||||
return _response_time;
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteProcessStatistics::get_turn_around() const
|
||||
{
|
||||
return _turn_around;
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteProcessStatistics::get_efficency() const
|
||||
{
|
||||
return _efficency;
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteProcessStatistics::get_resource_usage_time() const
|
||||
{
|
||||
return _resource_usage_time;
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteProcessStatistics::get_resource_waitings_time() const
|
||||
{
|
||||
return _resource_waitings_time;
|
||||
}
|
||||
|
||||
float
|
||||
ConcreteProcessStatistics::get_average_response_time() const
|
||||
{
|
||||
return _average_response_time;
|
||||
}
|
||||
|
||||
const Process*
|
||||
ConcreteProcessStatistics::get_core() const
|
||||
{
|
||||
return _core;
|
||||
}
|
||||
|
||||
/**
|
||||
\warning Don't delete these pointers!!
|
||||
\warning These pointers are not valid anymore after the destruction of "this"
|
||||
*/
|
||||
vector<const ThreadStatistics*>
|
||||
ConcreteProcessStatistics::get_threads_statistics() const
|
||||
{
|
||||
vector<const ThreadStatistics*> rit;
|
||||
for (uint i=0; i < _threads_stats.size(); i++)
|
||||
rit.push_back(&_threads_stats[i]);
|
||||
return rit;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
// src/backend/process_statistics.hh - Copyright 2005, 2006, University
|
||||
// src/backend/concrete_process_statistics.hh - Copyright 2005, 2006, University
|
||||
// of Padova, dept. of Pure and Applied
|
||||
// Mathematics
|
||||
//
|
||||
|
@ -18,26 +18,25 @@
|
|||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#ifndef PROCESS_STATISTICS_HH
|
||||
#define PROCESS_STATISTICS_HH 1
|
||||
#ifndef CONCRETE_PROCESS_STATISTICS_HH
|
||||
#define CONCRETE_PROCESS_STATISTICS_HH 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sgpemv2/schedulable_statistics.hh"
|
||||
#include "sgpemv2/process.hh"
|
||||
#include "thread_statistics.hh"
|
||||
#include <vector>
|
||||
|
||||
#include <glibmm/ustring.h>
|
||||
#include <sgpemv2/process_statistics.hh>
|
||||
#include <sgpemv2/thread_statistics.hh>
|
||||
#include "concrete_thread_statistics.hh"
|
||||
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class ProcessStatistics : public SchedulableStatistics
|
||||
class ConcreteStatistics;
|
||||
|
||||
class ConcreteProcessStatistics : public ProcessStatistics
|
||||
{
|
||||
public:
|
||||
ProcessStatistics(const Process* core, const int& instant);
|
||||
~ProcessStatistics();
|
||||
friend class ConcreteStatistics;
|
||||
~ConcreteProcessStatistics ();
|
||||
|
||||
int get_execution_time() const;
|
||||
int get_execution_progress() const;
|
||||
|
@ -50,14 +49,14 @@ namespace sgpem
|
|||
int get_resource_waitings_time() const;
|
||||
|
||||
const Process* get_core() const;
|
||||
|
||||
std::vector<ThreadStatistics> get_threads_statistics() const;
|
||||
|
||||
|
||||
std::vector<const ThreadStatistics*> get_threads_statistics() const;
|
||||
private:
|
||||
ConcreteProcessStatistics (const Process* core, const int& instant);
|
||||
|
||||
const Process* _core;
|
||||
float _average_response_time;
|
||||
std::vector<ThreadStatistics> _threads_stats;
|
||||
const Process* _core;
|
||||
float _average_response_time;
|
||||
std::vector<ConcreteThreadStatistics> _threads_stats;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
// src/backend/concrete_simulation_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_simulation_statistics.hh"
|
||||
#include <sgpemv2/statistics.hh>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace sgpem;
|
||||
|
||||
ConcreteSimulationStatistics::~ConcreteSimulationStatistics()
|
||||
{
|
||||
}
|
||||
|
||||
ConcreteSimulationStatistics::ConcreteSimulationStatistics(const std::vector<ConcreteProcessStatistics> proc_stats, const int& instant)
|
||||
{
|
||||
_average_inactivity_time = 0;
|
||||
_average_turn_around = 0;
|
||||
_average_response_time = 0;
|
||||
_average_efficency = 0;
|
||||
_terminated_processes = 0;
|
||||
_terminated_threads = 0;
|
||||
_average_throughput = 0;
|
||||
|
||||
int schedulables_count = 0;
|
||||
|
||||
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++)
|
||||
{
|
||||
schedulables_count++;
|
||||
_average_response_time += Tstats[t].get_response_time();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float
|
||||
ConcreteSimulationStatistics::get_average_inactivity_time() const
|
||||
{
|
||||
return _average_inactivity_time;
|
||||
}
|
||||
|
||||
float
|
||||
ConcreteSimulationStatistics::get_average_turn_around() const
|
||||
{
|
||||
return _average_turn_around;
|
||||
}
|
||||
|
||||
float
|
||||
ConcreteSimulationStatistics::get_average_response_time() const
|
||||
{
|
||||
return _average_response_time;
|
||||
}
|
||||
|
||||
float
|
||||
ConcreteSimulationStatistics::get_average_efficency() const
|
||||
{
|
||||
return _average_efficency;
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteSimulationStatistics::get_terminated_processes() const
|
||||
{
|
||||
return _terminated_processes;
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteSimulationStatistics::get_terminated_threads() const
|
||||
{
|
||||
return _terminated_threads;
|
||||
}
|
||||
|
||||
float
|
||||
ConcreteSimulationStatistics::get_average_throughput() const
|
||||
{
|
||||
return _average_throughput;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
// src/backend/concrete_simulation_statistics.hh - 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
|
||||
|
||||
#ifndef CONCRETE_SIMULATION_STATISTICS_HH
|
||||
#define CONCRETE_SIMULATION_STATISTICS_HH 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sgpemv2/simulation_statistics.hh>
|
||||
#include "concrete_process_statistics.hh"
|
||||
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class ConcreteStatistics;
|
||||
|
||||
class ConcreteSimulationStatistics : public SimulationStatistics
|
||||
{
|
||||
public:
|
||||
friend class ConcreteStatistics;
|
||||
|
||||
~ConcreteSimulationStatistics();
|
||||
|
||||
float get_average_inactivity_time() const ;
|
||||
float get_average_turn_around() const ;
|
||||
float get_average_response_time() const ;
|
||||
float get_average_efficency() const ;
|
||||
int get_terminated_processes() const ;
|
||||
int get_terminated_threads() const ;
|
||||
float get_average_throughput() const ;
|
||||
|
||||
protected:
|
||||
ConcreteSimulationStatistics(const std::vector<ConcreteProcessStatistics> proc_stats, const int& instant);
|
||||
|
||||
float _average_inactivity_time ;
|
||||
float _average_turn_around ;
|
||||
float _average_response_time ;
|
||||
float _average_efficency ;
|
||||
int _terminated_processes ;
|
||||
int _terminated_threads ;
|
||||
float _average_throughput ;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -19,55 +19,61 @@
|
|||
// 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 "thread_statistics.hh"
|
||||
#include "process_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()
|
||||
{}
|
||||
|
||||
|
||||
vector<ProcessStatistics>
|
||||
ConcreteStatistics::get_process_statistics(const int& instant) const
|
||||
|
||||
|
||||
ConcreteStatistics::ConcreteStatistics(): _sim_stats(0)
|
||||
{
|
||||
//vector<ThreadStatistics*> thread_stats;
|
||||
vector<ProcessStatistics> rit;
|
||||
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();
|
||||
|
||||
const History& hist = Simulation::get_instance().get_history();
|
||||
const Environment& env = hist.get_environment_at(instant);
|
||||
const vector<Process*> procs = env.get_processes();
|
||||
//create all process statistics (which themselves create their thread statistics)
|
||||
_proc_stats.clear();
|
||||
for (uint p = 0; p < procs.size(); p++)
|
||||
_proc_stats.push_back(ConcreteProcessStatistics(procs[p], instant));
|
||||
|
||||
//first calculate all THREADS statistics
|
||||
for (uint i_p=0; i_p < procs.size(); i_p++)
|
||||
{
|
||||
/*const vector<Thread*> threads = procs[i_p]->get_threads();
|
||||
for (uint i_t = 0; i_t < threads.size(); i_t++)
|
||||
{
|
||||
ThreadStatistics* s = new ThreadStatistics(threads[i_t], instant);
|
||||
thread_stats.push_back(s);
|
||||
rit.push_back(s);
|
||||
}
|
||||
*/
|
||||
rit.push_back(ProcessStatistics(procs[i_p], instant));
|
||||
}
|
||||
/*
|
||||
//then calculate PROCESSES statistics USING the previous ones
|
||||
for (uint i_p=0; i_p < procs.size(); i_p++)
|
||||
{
|
||||
SchedulableStatistics* s = new ProcessStatistics(procs[i_p], instant, &thread_stats);
|
||||
rit.push_back(s);
|
||||
}
|
||||
*/
|
||||
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 (uint i=0; i < _proc_stats.size(); i++)
|
||||
rit.push_back(&_proc_stats[i]);
|
||||
return rit;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,9 +23,12 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include "sgpemv2/statistics.hh"
|
||||
#include <glibmm/ustring.h>
|
||||
#include <sgpemv2/statistics.hh>
|
||||
#include "concrete_process_statistics.hh"
|
||||
#include "concrete_simulation_statistics.hh"
|
||||
|
||||
#include <glibmm/ustring.h>
|
||||
#include <vector>
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
|
@ -36,10 +39,18 @@ namespace sgpem
|
|||
public:
|
||||
ConcreteStatistics();
|
||||
|
||||
std::vector<ProcessStatistics> get_process_statistics(const int& instant) const;
|
||||
void calculateStatisticsAt(const int& instant);
|
||||
|
||||
const SimulationStatistics* get_simulation_statistics() const;
|
||||
std::vector<const ProcessStatistics*> get_process_statistics() const;
|
||||
|
||||
private:
|
||||
|
||||
ConcreteSimulationStatistics* _sim_stats;
|
||||
std::vector<ConcreteProcessStatistics> _proc_stats;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,193 @@
|
|||
// src/backend/concrete_thread_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_thread_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 <sgpemv2/resource.hh>
|
||||
#include <sgpemv2/request.hh>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace sgpem;
|
||||
|
||||
/**
|
||||
The constructor executes all calculations examinating or only the Thread object
|
||||
or the whole History
|
||||
|
||||
*/
|
||||
ConcreteThreadStatistics::ConcreteThreadStatistics(const Thread* core, const int& instant): _core(core)
|
||||
{
|
||||
//initializations
|
||||
_total_inactivity = 0;
|
||||
_execution_time = 0;
|
||||
_response_time = -1;
|
||||
_real_arrival_time = -1;
|
||||
_turn_around = 0;
|
||||
_resource_usage_time = 0;
|
||||
_resource_waitings_time = 0;
|
||||
|
||||
bool iniziato = false; //useful for _response_time
|
||||
|
||||
const History& hist = Simulation::get_instance().get_history(); //prendo la lista delle risorse
|
||||
const map<Environment::resource_key_t, Resource*> res = hist.get_environment_at(0).get_resources();
|
||||
|
||||
//****** iterate through HISTORY to retreive informations
|
||||
for (int time=0; time < instant; time++)
|
||||
{
|
||||
const Environment& env = hist.get_environment_at(time);
|
||||
const vector<Process*> procs = env.get_processes();
|
||||
|
||||
//looks for the process that owns this thread
|
||||
for (uint i_p=0; i_p < procs.size(); i_p++)
|
||||
{
|
||||
const vector<Thread*> threads = procs[i_p]->get_threads();
|
||||
//looks for the thread "core"
|
||||
for (uint i_t = 0; i_t < threads.size(); i_t++)
|
||||
{
|
||||
if ( (*threads[i_t]) == (*core) ) //FOUND!!
|
||||
{
|
||||
if (threads[i_t]->get_state() == Schedulable::state_running)
|
||||
{
|
||||
iniziato = true;
|
||||
if( _response_time == -1) //arrives and runs immediately
|
||||
{
|
||||
_response_time = 0;
|
||||
_real_arrival_time = time - procs[i_p]->get_arrival_time() -1;
|
||||
}
|
||||
_execution_time++;
|
||||
}
|
||||
if (threads[i_t]->get_state() != Schedulable::state_future &&
|
||||
threads[i_t]->get_state() != Schedulable::state_terminated)
|
||||
{
|
||||
_turn_around++;
|
||||
if (!iniziato && _response_time == -1) //arrives and doesn't run
|
||||
{
|
||||
_response_time = 0;
|
||||
_real_arrival_time = time - procs[i_p]->get_arrival_time() -1;
|
||||
}
|
||||
}
|
||||
if (threads[i_t]->get_state() == Schedulable::state_blocked
|
||||
|| threads[i_t]->get_state() == Schedulable::state_ready)
|
||||
{
|
||||
_total_inactivity++;
|
||||
if (!iniziato && _response_time != -1)
|
||||
_response_time++;
|
||||
|
||||
if (threads[i_t]->get_state() == Schedulable::state_blocked)
|
||||
_resource_waitings_time++;
|
||||
}
|
||||
}
|
||||
} //threads
|
||||
} //procs
|
||||
|
||||
|
||||
//for each resource check requests at this istant:
|
||||
//if the request of this thread is allocated then increase _resource_usage_time
|
||||
Environment::Resources::const_iterator res_iter = res.begin();
|
||||
while(res_iter != res.end())
|
||||
{
|
||||
Environment::resource_key_t key = (*res_iter).first;
|
||||
vector<SubRequest*> req = env.get_request_queue(key);
|
||||
for (uint i_r=0; i_r < req.size(); i_r++)
|
||||
if( (*req[i_r]).get_request().get_thread() == (*core) && (*req[i_r]).get_state() == Request::state_allocated)
|
||||
_resource_usage_time++;
|
||||
|
||||
res_iter++;
|
||||
}
|
||||
|
||||
}//istants
|
||||
|
||||
//set other variables
|
||||
_execution_progress = (100*_execution_time)/core->get_total_cpu_time();
|
||||
if (_turn_around == 0)
|
||||
_efficency = -1;
|
||||
else
|
||||
_efficency = (_execution_time*100)/_turn_around;
|
||||
}
|
||||
|
||||
|
||||
ConcreteThreadStatistics::~ConcreteThreadStatistics()
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteThreadStatistics::get_execution_time() const
|
||||
{
|
||||
return _execution_time;
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteThreadStatistics::get_execution_progress() const
|
||||
{
|
||||
return _execution_progress;
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteThreadStatistics::get_total_inactivity() const
|
||||
{
|
||||
return _total_inactivity;
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteThreadStatistics::get_response_time() const
|
||||
{
|
||||
return _response_time;
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteThreadStatistics::get_turn_around() const
|
||||
{
|
||||
return _turn_around;
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteThreadStatistics::get_efficency() const
|
||||
{
|
||||
return _efficency;
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteThreadStatistics::get_resource_usage_time() const
|
||||
{
|
||||
return _resource_usage_time;
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteThreadStatistics::get_resource_waitings_time() const
|
||||
{
|
||||
return _resource_waitings_time;
|
||||
}
|
||||
|
||||
int
|
||||
ConcreteThreadStatistics::get_real_arrival_time() const
|
||||
{
|
||||
return _real_arrival_time;
|
||||
}
|
||||
|
||||
const Thread*
|
||||
ConcreteThreadStatistics::get_core() const
|
||||
{
|
||||
return _core;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
// src/backend/thread_statistics.hh - Copyright 2005, 2006, University
|
||||
// src/backend/concrete_thread_statistics.hh - Copyright 2005, 2006, University
|
||||
// of Padova, dept. of Pure and Applied
|
||||
// Mathematics
|
||||
//
|
||||
|
@ -18,24 +18,25 @@
|
|||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#ifndef THREAD_STATISTICS_HH
|
||||
#define THREAD_STATISTICS_HH 1
|
||||
#ifndef CONCRETE_THREAD_STATISTICS_HH
|
||||
#define CONCRETE_THREAD_STATISTICS_HH 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sgpemv2/schedulable_statistics.hh"
|
||||
#include "sgpemv2/thread.hh"
|
||||
#include <sgpemv2/thread_statistics.hh>
|
||||
|
||||
#include <glibmm/ustring.h>
|
||||
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class ThreadStatistics : public SchedulableStatistics
|
||||
class ConcreteProcessStatistics;
|
||||
|
||||
class ConcreteThreadStatistics : public ThreadStatistics
|
||||
{
|
||||
public:
|
||||
ThreadStatistics(const Thread* core, const int& instant);
|
||||
~ThreadStatistics();
|
||||
public:
|
||||
friend class ConcreteProcessStatistics;
|
||||
~ConcreteThreadStatistics();
|
||||
|
||||
int get_execution_time() const;
|
||||
int get_execution_progress() const;
|
||||
|
@ -51,6 +52,7 @@ namespace sgpem
|
|||
int get_real_arrival_time() const; //useful for ProcessStatistics
|
||||
|
||||
private:
|
||||
ConcreteThreadStatistics(const Thread* core, const int& instant);
|
||||
const Thread* _core;
|
||||
int _real_arrival_time;
|
||||
};
|
|
@ -18,176 +18,16 @@
|
|||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "process_statistics.hh"
|
||||
#include "sgpemv2/simulation.hh"
|
||||
#include "sgpemv2/history.hh"
|
||||
#include "sgpemv2/environment.hh"
|
||||
#include "sgpemv2/schedulable.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
#include <sgpemv2/process_statistics.hh>
|
||||
using namespace sgpem;
|
||||
|
||||
/**
|
||||
The constructor executes all calculations examinating or only the Thred object,
|
||||
or the whole History
|
||||
|
||||
*/
|
||||
ProcessStatistics::ProcessStatistics(const Process* core, const int& instant): _core(core)
|
||||
{
|
||||
// To calculate Process statistics we need the respective thread statistics
|
||||
// Calculate them!
|
||||
|
||||
vector<const Thread*> threads = core->get_threads();
|
||||
for (uint i_t = 0; i_t < threads.size(); i_t++)
|
||||
_threads_stats.push_back(ThreadStatistics(threads[i_t], instant));
|
||||
|
||||
//inizialize variables
|
||||
_total_inactivity = 0;
|
||||
_execution_time = 0;
|
||||
_response_time = -1;
|
||||
_turn_around = 0;
|
||||
_resource_usage_time = 0;
|
||||
_resource_waitings_time = 0;
|
||||
_average_response_time = 0;
|
||||
int min_reponse = -1; //useful for _response_time
|
||||
int arrived_threads = 0; //useful for _average_response_time
|
||||
bool someone_began = false; //useful for _response_time
|
||||
|
||||
//iterate through threads statistics
|
||||
vector<ThreadStatistics>::iterator i;
|
||||
for(i = _threads_stats.begin(); i != _threads_stats.end(); i++)
|
||||
{
|
||||
Thread* t = const_cast<Thread*>((*i).get_core());
|
||||
if (t->get_process() == *core)
|
||||
{ //found a thread belonging to "core"
|
||||
|
||||
_execution_time += (*i).get_execution_time();
|
||||
_resource_usage_time += (*i).get_resource_usage_time();
|
||||
|
||||
if ((*i).get_response_time() != -1)
|
||||
{
|
||||
_average_response_time += (*i).get_response_time();
|
||||
arrived_threads++;
|
||||
}
|
||||
|
||||
if ((*i).get_response_time() != -1 && someone_began == false)
|
||||
{
|
||||
someone_began = true;
|
||||
min_reponse = (*i).get_response_time();
|
||||
}
|
||||
|
||||
if(someone_began && (*i).get_response_time() != -1 && (*i).get_response_time() + (*i).get_real_arrival_time() < min_reponse)
|
||||
min_reponse = (*i).get_response_time() + (*i).get_real_arrival_time();
|
||||
|
||||
if ((*i).get_real_arrival_time() + (*i).get_execution_time() + (*i).get_total_inactivity() > _turn_around)
|
||||
_turn_around = (*i).get_real_arrival_time() + (*i).get_execution_time() + (*i).get_total_inactivity();
|
||||
}
|
||||
}
|
||||
|
||||
//******* AAARRRGGHH!!!
|
||||
//We have to iterate the whole History ONLY to retreive _resource_waitings_time !!
|
||||
//
|
||||
const History& hist = Simulation::get_instance().get_history();
|
||||
for (int time=0; time < instant; time++)
|
||||
{
|
||||
const Environment& env = hist.get_environment_at(time);
|
||||
const vector<Process*> procs = env.get_processes();
|
||||
|
||||
for (uint i_p=0; i_p < procs.size(); i_p++)
|
||||
if (*procs[i_p] == *core && procs[i_p]->get_state() == Schedulable::state_blocked)
|
||||
_resource_waitings_time++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//set other variables
|
||||
if(core->get_total_cpu_time() != 0)
|
||||
_execution_progress = (_execution_time*100) / core->get_total_cpu_time();
|
||||
else
|
||||
_execution_progress = 0;
|
||||
|
||||
_total_inactivity = _turn_around - _execution_time;
|
||||
|
||||
if (_turn_around == 0)
|
||||
_efficency = -1;
|
||||
else
|
||||
_efficency = (_execution_time*100)/_turn_around;
|
||||
|
||||
_response_time = min_reponse;
|
||||
|
||||
if (arrived_threads != 0)
|
||||
_average_response_time = (float)((int)((_average_response_time/arrived_threads)*100))/100;
|
||||
}
|
||||
|
||||
|
||||
ProcessStatistics::~ProcessStatistics()
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
ProcessStatistics::get_execution_time() const
|
||||
ProcessStatistics::ProcessStatistics()
|
||||
{
|
||||
return _execution_time;
|
||||
}
|
||||
|
||||
int
|
||||
ProcessStatistics::get_execution_progress() const
|
||||
{
|
||||
return _execution_progress;
|
||||
}
|
||||
|
||||
int
|
||||
ProcessStatistics::get_total_inactivity() const
|
||||
{
|
||||
return _total_inactivity;
|
||||
}
|
||||
|
||||
int
|
||||
ProcessStatistics::get_response_time() const
|
||||
{
|
||||
return _response_time;
|
||||
}
|
||||
|
||||
int
|
||||
ProcessStatistics::get_turn_around() const
|
||||
{
|
||||
return _turn_around;
|
||||
}
|
||||
|
||||
int
|
||||
ProcessStatistics::get_efficency() const
|
||||
{
|
||||
return _efficency;
|
||||
}
|
||||
|
||||
int
|
||||
ProcessStatistics::get_resource_usage_time() const
|
||||
{
|
||||
return _resource_usage_time;
|
||||
}
|
||||
|
||||
int
|
||||
ProcessStatistics::get_resource_waitings_time() const
|
||||
{
|
||||
return _resource_waitings_time;
|
||||
}
|
||||
|
||||
float
|
||||
ProcessStatistics::get_average_response_time() const
|
||||
{
|
||||
return _average_response_time;
|
||||
}
|
||||
|
||||
const Process*
|
||||
ProcessStatistics::get_core() const
|
||||
{
|
||||
return _core;
|
||||
}
|
||||
|
||||
vector<ThreadStatistics>
|
||||
ProcessStatistics::get_threads_statistics() const
|
||||
{
|
||||
return _threads_stats;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
// src/backend/process_statistics.hh - 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
|
||||
|
||||
#ifndef PROCESS_STATISTICS_HH
|
||||
#define PROCESS_STATISTICS_HH 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sgpemv2/schedulable_statistics.hh>
|
||||
#include <sgpemv2/thread_statistics.hh>
|
||||
#include <sgpemv2/process.hh>
|
||||
#include "thread_statistics.hh"
|
||||
#include <vector>
|
||||
|
||||
#include <glibmm/ustring.h>
|
||||
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class ProcessStatistics : public SchedulableStatistics
|
||||
{
|
||||
public:
|
||||
~ProcessStatistics();
|
||||
|
||||
int get_execution_time() const =0;
|
||||
int get_execution_progress() const =0;
|
||||
int get_total_inactivity() const =0;
|
||||
int get_response_time() const =0;
|
||||
virtual float get_average_response_time() const =0;
|
||||
int get_turn_around() const =0;
|
||||
int get_efficency() const =0;
|
||||
int get_resource_usage_time() const =0;
|
||||
int get_resource_waitings_time() const =0;
|
||||
|
||||
const Process* get_core() const =0;
|
||||
|
||||
virtual std::vector<const ThreadStatistics*> get_threads_statistics() const =0;
|
||||
|
||||
protected:
|
||||
ProcessStatistics();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,51 @@
|
|||
// src/backend/simulation_statistics.hh - 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
|
||||
|
||||
#ifndef SIMULATION_STATISTICS_HH
|
||||
#define SIMULATION_STATISTICS_HH 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class SimulationStatistics
|
||||
{
|
||||
public:
|
||||
virtual ~SimulationStatistics();
|
||||
|
||||
virtual float get_average_inactivity_time() const =0;
|
||||
virtual float get_average_turn_around() const =0;
|
||||
virtual float get_average_response_time() const =0;
|
||||
virtual float get_average_efficency() const =0;
|
||||
virtual int get_terminated_processes() const =0;
|
||||
virtual int get_terminated_threads() const =0;
|
||||
virtual float get_average_throughput() const =0;
|
||||
|
||||
protected:
|
||||
|
||||
SimulationStatistics();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -22,8 +22,9 @@
|
|||
#define STATISTICS_HH 1
|
||||
|
||||
#include "config.h"
|
||||
#include "sgpemv2/templates/singleton.hh"
|
||||
#include "process_statistics.hh"
|
||||
#include <sgpemv2/templates/singleton.hh>
|
||||
#include <sgpemv2/process_statistics.hh>
|
||||
#include <sgpemv2/simulation_statistics.hh>
|
||||
#include <vector>
|
||||
|
||||
#include <glibmm/ustring.h>
|
||||
|
@ -35,13 +36,14 @@ namespace sgpem
|
|||
|
||||
class SG_DLLEXPORT Statistics : public Singleton<ConcreteStatistics>
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
public:
|
||||
virtual ~Statistics() = 0;
|
||||
static Statistics& get_instance();
|
||||
|
||||
virtual std::vector<ProcessStatistics> get_process_statistics(const int& instant) const = 0;
|
||||
virtual void calculateStatisticsAt(const int& instant) = 0;
|
||||
|
||||
virtual std::vector<const ProcessStatistics*> get_process_statistics() const = 0;
|
||||
virtual const SimulationStatistics* get_simulation_statistics() const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -51,3 +53,5 @@ namespace sgpem
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
// src/backend/thread_statistics.hh - 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
|
||||
|
||||
#ifndef THREAD_STATISTICS_HH
|
||||
#define THREAD_STATISTICS_HH 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sgpemv2/schedulable_statistics.hh>
|
||||
#include <sgpemv2/thread.hh>
|
||||
|
||||
#include <glibmm/ustring.h>
|
||||
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class ThreadStatistics : public SchedulableStatistics
|
||||
{
|
||||
public:
|
||||
~ThreadStatistics();
|
||||
|
||||
int get_execution_time() const =0;
|
||||
int get_execution_progress() const =0;
|
||||
int get_total_inactivity() const =0;
|
||||
int get_response_time() const =0;
|
||||
int get_turn_around() const =0;
|
||||
int get_efficency() const =0;
|
||||
int get_resource_usage_time() const =0;
|
||||
int get_resource_waitings_time() const =0;
|
||||
|
||||
const Thread* get_core() const =0;
|
||||
|
||||
virtual int get_real_arrival_time() const =0; //useful for ProcessStatistics
|
||||
|
||||
protected:
|
||||
ThreadStatistics();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,31 @@
|
|||
// src/backend/simulation_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 <sgpemv2/simulation_statistics.hh>
|
||||
|
||||
using namespace sgpem;
|
||||
|
||||
SimulationStatistics::~SimulationStatistics()
|
||||
{}
|
||||
|
||||
SimulationStatistics::SimulationStatistics()
|
||||
{}
|
||||
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "sgpemv2/statistics.hh"
|
||||
#include <sgpemv2/statistics.hh>
|
||||
#include "concrete_statistics.hh"
|
||||
|
||||
// Do not include in header file:
|
||||
|
@ -36,4 +36,9 @@ Statistics&
|
|||
Statistics::get_instance()
|
||||
{
|
||||
return Singleton<ConcreteStatistics>::get_instance();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -18,176 +18,16 @@
|
|||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "thread_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 "sgpemv2/resource.hh"
|
||||
#include "sgpemv2/request.hh"
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
#include <sgpemv2/thread_statistics.hh>
|
||||
|
||||
using namespace sgpem;
|
||||
|
||||
/**
|
||||
The constructor executes all calculations examinating or only the Thread object
|
||||
or the whole History
|
||||
|
||||
*/
|
||||
ThreadStatistics::ThreadStatistics(const Thread* core, const int& instant): _core(core)
|
||||
ThreadStatistics::ThreadStatistics()
|
||||
{
|
||||
//initializations
|
||||
_total_inactivity = 0;
|
||||
_execution_time = 0;
|
||||
_response_time = -1;
|
||||
_real_arrival_time = -1;
|
||||
_turn_around = 0;
|
||||
_resource_usage_time = 0;
|
||||
_resource_waitings_time = 0;
|
||||
|
||||
bool iniziato = false; //useful for _response_time
|
||||
|
||||
const History& hist = Simulation::get_instance().get_history(); //prendo la lista delle risorse
|
||||
const map<Environment::resource_key_t, Resource*> res = hist.get_environment_at(0).get_resources();
|
||||
|
||||
//****** iterate through HISTORY to retreive informations
|
||||
for (int time=0; time < instant; time++)
|
||||
{
|
||||
const Environment& env = hist.get_environment_at(time);
|
||||
const vector<Process*> procs = env.get_processes();
|
||||
|
||||
//looks for the process that owns this thread
|
||||
for (uint i_p=0; i_p < procs.size(); i_p++)
|
||||
{
|
||||
const vector<Thread*> threads = procs[i_p]->get_threads();
|
||||
//looks for the thread "core"
|
||||
for (uint i_t = 0; i_t < threads.size(); i_t++)
|
||||
{
|
||||
if ( (*threads[i_t]) == (*core) ) //FOUND!!
|
||||
{
|
||||
if (threads[i_t]->get_state() == Schedulable::state_running)
|
||||
{
|
||||
iniziato = true;
|
||||
if( _response_time == -1) //arrives and runs immediately
|
||||
{
|
||||
_response_time = 0;
|
||||
_real_arrival_time = time - procs[i_p]->get_arrival_time() -1;
|
||||
}
|
||||
_execution_time++;
|
||||
}
|
||||
if (threads[i_t]->get_state() != Schedulable::state_future &&
|
||||
threads[i_t]->get_state() != Schedulable::state_terminated)
|
||||
{
|
||||
_turn_around++;
|
||||
if (!iniziato && _response_time == -1) //arrives and doesn't run
|
||||
{
|
||||
_response_time = 0;
|
||||
_real_arrival_time = time - procs[i_p]->get_arrival_time() -1;
|
||||
}
|
||||
}
|
||||
if (threads[i_t]->get_state() == Schedulable::state_blocked
|
||||
|| threads[i_t]->get_state() == Schedulable::state_ready)
|
||||
{
|
||||
_total_inactivity++;
|
||||
if (!iniziato && _response_time != -1)
|
||||
_response_time++;
|
||||
|
||||
if (threads[i_t]->get_state() == Schedulable::state_blocked)
|
||||
_resource_waitings_time++;
|
||||
}
|
||||
}
|
||||
} //threads
|
||||
} //procs
|
||||
|
||||
|
||||
//for each resource check requests at this istant:
|
||||
//if the request of this thread is allocated then increase _resource_usage_time
|
||||
Environment::Resources::const_iterator res_iter = res.begin();
|
||||
while(res_iter != res.end())
|
||||
{
|
||||
Environment::resource_key_t key = (*res_iter).first;
|
||||
vector<SubRequest*> req = env.get_request_queue(key);
|
||||
for (uint i_r=0; i_r < req.size(); i_r++)
|
||||
if( (*req[i_r]).get_request().get_thread() == (*core) && (*req[i_r]).get_state() == Request::state_allocated)
|
||||
_resource_usage_time++;
|
||||
|
||||
res_iter++;
|
||||
}
|
||||
|
||||
}//istants
|
||||
|
||||
//set other variables
|
||||
_execution_progress = (100*_execution_time)/core->get_total_cpu_time();
|
||||
if (_turn_around == 0)
|
||||
_efficency = -1;
|
||||
else
|
||||
_efficency = (_execution_time*100)/_turn_around;
|
||||
}
|
||||
|
||||
|
||||
ThreadStatistics::~ThreadStatistics()
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
ThreadStatistics::get_execution_time() const
|
||||
{
|
||||
return _execution_time;
|
||||
}
|
||||
|
||||
int
|
||||
ThreadStatistics::get_execution_progress() const
|
||||
{
|
||||
return _execution_progress;
|
||||
}
|
||||
|
||||
int
|
||||
ThreadStatistics::get_total_inactivity() const
|
||||
{
|
||||
return _total_inactivity;
|
||||
}
|
||||
|
||||
int
|
||||
ThreadStatistics::get_response_time() const
|
||||
{
|
||||
return _response_time;
|
||||
}
|
||||
|
||||
int
|
||||
ThreadStatistics::get_turn_around() const
|
||||
{
|
||||
return _turn_around;
|
||||
}
|
||||
|
||||
int
|
||||
ThreadStatistics::get_efficency() const
|
||||
{
|
||||
return _efficency;
|
||||
}
|
||||
|
||||
int
|
||||
ThreadStatistics::get_resource_usage_time() const
|
||||
{
|
||||
return _resource_usage_time;
|
||||
}
|
||||
|
||||
int
|
||||
ThreadStatistics::get_resource_waitings_time() const
|
||||
{
|
||||
return _resource_waitings_time;
|
||||
}
|
||||
|
||||
int
|
||||
ThreadStatistics::get_real_arrival_time() const
|
||||
{
|
||||
return _real_arrival_time;
|
||||
}
|
||||
|
||||
const Thread*
|
||||
ThreadStatistics::get_core() const
|
||||
{
|
||||
return _core;
|
||||
}
|
||||
|
|
|
@ -616,6 +616,10 @@ GuiBuilder::GuiBuilder(const std::string& gladefile)
|
|||
_holt_container.set_keep_above();
|
||||
_holt_container.get_holt_widget().set_show_threads(_show_threads);
|
||||
_holt_container.show();
|
||||
|
||||
// Statistics container window
|
||||
_statistics_container.set_keep_above();
|
||||
_statistics_container.show();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "holt_container_window.hh"
|
||||
#include "statistics_container_window.hh"
|
||||
#include "simulation_widget.hh"
|
||||
|
||||
#include <sgpemv2/cpu_policy.hh>
|
||||
|
@ -80,6 +81,7 @@ namespace sgpem
|
|||
std::string _filename;
|
||||
|
||||
HoltContainerWindow _holt_container;
|
||||
StatisticsContainerWindow _statistics_container;
|
||||
SimulationWidget* _simulation_widget;
|
||||
bool _show_threads;
|
||||
|
||||
|
|
|
@ -1,3 +1,23 @@
|
|||
// src/holt_container_window.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 "holt_container_window.hh"
|
||||
|
||||
using namespace sgpem;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// src/simulation_widget.hh - Copyright 2005, 2006, University
|
||||
// src/holt_container_window.hh - Copyright 2005, 2006, University
|
||||
// of Padova, dept. of Pure and Applied
|
||||
// Mathematics
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// src/simulation_widget.cc - Copyright 2005, 2006, University
|
||||
// src/holt_widget.cc - Copyright 2005, 2006, University
|
||||
// of Padova, dept. of Pure and Applied
|
||||
// Mathematics
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// src/simulation_widget.hh - Copyright 2005, 2006, University
|
||||
// src/holt_widget.hh - Copyright 2005, 2006, University
|
||||
// of Padova, dept. of Pure and Applied
|
||||
// Mathematics
|
||||
//
|
||||
|
|
|
@ -0,0 +1,321 @@
|
|||
// src/schedulables_statistics_widget.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 "gettext.h"
|
||||
|
||||
|
||||
#include "schedulables_statistics_widget.hh"
|
||||
#include <sgpemv2/simulation.hh>
|
||||
#include <sgpemv2/history.hh>
|
||||
#include <sgpemv2/statistics.hh>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
using namespace sgpem;
|
||||
using namespace std;
|
||||
|
||||
using namespace Gtk;
|
||||
using namespace Glib;
|
||||
|
||||
|
||||
TabularSchedulableStatisticsWidget::TabularSchedulableStatisticsWidget()
|
||||
{
|
||||
|
||||
_show_runs = _show_perc = _show_inactive = _show_turn =
|
||||
_show_resp = _show_effic =
|
||||
_show_ris_usage = _show_ris_block = true;
|
||||
|
||||
//insert columns
|
||||
_columns.add(_col_name);
|
||||
_columns.add(_col_runs);
|
||||
_columns.add(_col_perc);
|
||||
_columns.add(_col_inactive);
|
||||
_columns.add(_col_turn);
|
||||
_columns.add(_col_resp);
|
||||
_columns.add(_col_effic);
|
||||
_columns.add(_col_ris_usage);
|
||||
_columns.add(_col_ris_block);
|
||||
|
||||
_model = TreeStore::create(_columns);
|
||||
set_model(_model);
|
||||
|
||||
//show only columns chosen by the user
|
||||
update_columns();
|
||||
|
||||
set_headers_visible(true);
|
||||
|
||||
// Register this HistoryObserver:
|
||||
Simulation::get_instance().get_history().attach(*this);
|
||||
}
|
||||
|
||||
TabularSchedulableStatisticsWidget::~TabularSchedulableStatisticsWidget()
|
||||
{
|
||||
Simulation::get_instance().get_history().detach(*this);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TabularSchedulableStatisticsWidget::update(const History& changed_history)
|
||||
{
|
||||
_model->clear();
|
||||
|
||||
Statistics::get_instance().calculateStatisticsAt(changed_history.get_front());
|
||||
vector<const ProcessStatistics*> p_stats = Statistics::get_instance().get_process_statistics();
|
||||
|
||||
for(unsigned int i_p = 0; i_p < p_stats.size(); i_p++)
|
||||
{
|
||||
TreeModel::Row riga_P = *(_model->append());
|
||||
|
||||
riga_P[_col_name] = p_stats[i_p]->get_core()->get_name();
|
||||
riga_P[_col_runs] = p_stats[i_p]->get_execution_time();
|
||||
stringstream s1; s1 << p_stats[i_p]->get_execution_progress() << "%";
|
||||
riga_P[_col_perc] = Glib::ustring(s1.str());
|
||||
riga_P[_col_inactive]= p_stats[i_p]->get_total_inactivity();
|
||||
stringstream s2;
|
||||
if (p_stats[i_p]->get_response_time() != -1)
|
||||
s2 << p_stats[i_p]->get_response_time() << " (avg:" << p_stats[i_p]->get_average_response_time() << ")";
|
||||
else
|
||||
s2 << "---";
|
||||
riga_P[_col_resp] = Glib::ustring(s2.str());
|
||||
riga_P[_col_turn] = p_stats[i_p]->get_turn_around();
|
||||
stringstream s3;
|
||||
if (p_stats[i_p]->get_efficency() != -1)
|
||||
s3 << p_stats[i_p]->get_efficency() << "%";
|
||||
else
|
||||
s3 << "---";
|
||||
riga_P[_col_effic] = Glib::ustring(s3.str());
|
||||
riga_P[_col_ris_usage] = p_stats[i_p]->get_resource_usage_time();
|
||||
riga_P[_col_ris_block] = p_stats[i_p]->get_resource_waitings_time();
|
||||
|
||||
vector<const ThreadStatistics*> t_stats = p_stats[i_p]->get_threads_statistics();
|
||||
|
||||
for(unsigned int i_t = 0; i_t < t_stats.size(); i_t++)
|
||||
{
|
||||
TreeModel::Row riga_T = *(_model->append(riga_P.children()));
|
||||
riga_T[_col_name] = t_stats[i_t]->get_core()->get_name();
|
||||
riga_T[_col_runs] = t_stats[i_t]->get_execution_time();
|
||||
stringstream s1; s1 << t_stats[i_t]->get_execution_progress() << "%";
|
||||
riga_T[_col_perc] = Glib::ustring(s1.str());
|
||||
riga_T[_col_inactive]= t_stats[i_t]->get_total_inactivity();
|
||||
stringstream s2;
|
||||
if (t_stats[i_t]->get_response_time() != -1)
|
||||
s2 << t_stats[i_t]->get_response_time();
|
||||
else
|
||||
s2 << "---";
|
||||
riga_T[_col_resp] = Glib::ustring(s2.str());
|
||||
riga_T[_col_turn] = t_stats[i_t]->get_turn_around();
|
||||
stringstream s3;
|
||||
if (t_stats[i_t]->get_efficency() != -1)
|
||||
s3 <<t_stats[i_t]->get_efficency() << "%";
|
||||
else
|
||||
s3 << "---";
|
||||
riga_T[_col_effic] = Glib::ustring(s3.str());
|
||||
riga_T[_col_ris_usage] = t_stats[i_t]->get_resource_usage_time();
|
||||
riga_T[_col_ris_block] = t_stats[i_t]->get_resource_waitings_time();
|
||||
}
|
||||
}
|
||||
expand_all();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TabularSchedulableStatisticsWidget::update_columns()
|
||||
{
|
||||
remove_all_columns();
|
||||
|
||||
append_column(_("Schedulable"), _col_name);
|
||||
|
||||
if (_show_runs)
|
||||
append_column(_("Running"), _col_runs);
|
||||
|
||||
if (_show_perc )
|
||||
append_column(_("Completed"), _col_perc);
|
||||
|
||||
if (_show_inactive)
|
||||
append_column(_("Inactivity"), _col_inactive);
|
||||
|
||||
if (_show_turn)
|
||||
append_column(_("Turn Around"), _col_turn);
|
||||
|
||||
if (_show_resp)
|
||||
append_column(_("Response"), _col_resp);
|
||||
|
||||
//if (_show_turn)
|
||||
// append_column(_("Turn Around"), _col_inactive);
|
||||
|
||||
if (_show_effic)
|
||||
append_column(_("Efficency"), _col_effic);
|
||||
|
||||
if (_show_ris_usage)
|
||||
append_column(_("Res. usage"), _col_ris_usage);
|
||||
|
||||
if (_show_ris_block)
|
||||
append_column(_("Res. block"), _col_ris_block);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
TabularSchedulableStatisticsWidget::set_show_runs(bool b)
|
||||
{
|
||||
_show_runs = b;
|
||||
}
|
||||
|
||||
bool
|
||||
TabularSchedulableStatisticsWidget::get_show_runs() const
|
||||
{
|
||||
return _show_runs;
|
||||
}
|
||||
|
||||
void
|
||||
TabularSchedulableStatisticsWidget::set_show_perc(bool b)
|
||||
{
|
||||
_show_perc = b;
|
||||
}
|
||||
|
||||
bool
|
||||
TabularSchedulableStatisticsWidget::get_show_perc() const
|
||||
{
|
||||
return _show_perc;
|
||||
}
|
||||
|
||||
void
|
||||
TabularSchedulableStatisticsWidget::set_show_inactive(bool b)
|
||||
{
|
||||
_show_inactive = b;
|
||||
}
|
||||
|
||||
bool
|
||||
TabularSchedulableStatisticsWidget::get_show_inactive() const
|
||||
{
|
||||
return _show_inactive;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TabularSchedulableStatisticsWidget::set_show_turn_around(bool b)
|
||||
{
|
||||
_show_turn = b;
|
||||
}
|
||||
|
||||
bool
|
||||
TabularSchedulableStatisticsWidget::get_show_turn_around() const
|
||||
{
|
||||
return _show_turn;
|
||||
}
|
||||
|
||||
void
|
||||
TabularSchedulableStatisticsWidget::set_show_response(bool b)
|
||||
{
|
||||
_show_resp = b;
|
||||
}
|
||||
|
||||
bool
|
||||
TabularSchedulableStatisticsWidget::get_show_response() const
|
||||
{
|
||||
return _show_resp;
|
||||
}
|
||||
|
||||
void
|
||||
TabularSchedulableStatisticsWidget::set_show_efficency(bool b)
|
||||
{
|
||||
_show_effic = b;
|
||||
}
|
||||
|
||||
bool
|
||||
TabularSchedulableStatisticsWidget::get_show_efficency() const
|
||||
{
|
||||
return _show_effic;
|
||||
}
|
||||
|
||||
void
|
||||
TabularSchedulableStatisticsWidget::set_show_resource_usage(bool b)
|
||||
{
|
||||
_show_ris_usage= b;
|
||||
}
|
||||
|
||||
bool
|
||||
TabularSchedulableStatisticsWidget::get_show_resource_usage() const
|
||||
{
|
||||
return _show_ris_usage;
|
||||
}
|
||||
|
||||
void
|
||||
TabularSchedulableStatisticsWidget::set_show_resource_block(bool b)
|
||||
{
|
||||
_show_ris_block= b;
|
||||
}
|
||||
|
||||
bool
|
||||
TabularSchedulableStatisticsWidget::get_show_resource_block() const
|
||||
{
|
||||
return _show_ris_block;
|
||||
}
|
||||
|
||||
/*
|
||||
void
|
||||
TabularSchedulableStatisticsWidget::draw_widget(cairo_t* ctx)
|
||||
{
|
||||
cout << "\nTabularSchedulableStatisticsWidget::draw_widget";
|
||||
|
||||
|
||||
// draw text: T = n as title
|
||||
|
||||
const History& hist = Simulation::get_instance().get_history();
|
||||
cairo_text_extents_t extents;
|
||||
stringstream ss;
|
||||
ss << "!CIAO MONDO!" ;
|
||||
cairo_text_extents(ctx, ss.str().c_str(), &extents);
|
||||
cairo_move_to(ctx, _draw_w/2 - extents.width/2.0, extents.height*2.0);
|
||||
cairo_show_text(ctx, ss.str().c_str());
|
||||
|
||||
|
||||
//cairo_save(ctx);
|
||||
//cairo_set_source(ctx, _running_process_gradient);
|
||||
// cairo_matrix_init_scale(&matrix, 1.0, y);
|
||||
// cairo_matrix_translate(&matrix, 0, -y);
|
||||
//cairo_matrix_init_translate(&matrix, 0, -y);
|
||||
//cairo_pattern_set_matrix (_running_process_gradient, &matrix);
|
||||
cairo_set_source_rgba(ctx, 1,0,0,1);
|
||||
cairo_rectangle(ctx, 0.5, 0.5, 10, 10);
|
||||
cairo_fill(ctx);
|
||||
|
||||
//cairo_restore(ctx);
|
||||
//break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TabularSchedulableStatisticsWidget::calc_drawing_size(cairo_t* ctx, size_t& width, size_t& height)
|
||||
{
|
||||
cout << "\nHolt widget calc_drawing_size";
|
||||
}
|
||||
|
||||
void
|
||||
TabularSchedulableStatisticsWidget::calc_widget_size(size_t& width, size_t& height)
|
||||
{
|
||||
cout << "\nHolt widget calc_widget_size";
|
||||
//width = height = 20; // default minimum size
|
||||
}
|
||||
|
||||
*/
|
|
@ -0,0 +1,98 @@
|
|||
// src/schedulable_statistics_widget.hh - 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
|
||||
|
||||
#ifndef SCHEDULABLE_STATISTICS_WIDGET_HH
|
||||
#define SCHEDULABLE_STATISTICS_WIDGET_HH 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "cairo_widget.hh"
|
||||
#include <sgpemv2/history_observer.hh>
|
||||
|
||||
#include <gtkmm/treeview.h>
|
||||
#include <gtkmm/treestore.h>
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
|
||||
|
||||
class TabularSchedulableStatisticsWidget : public HistoryObserver, public Gtk::TreeView
|
||||
{
|
||||
public:
|
||||
TabularSchedulableStatisticsWidget();
|
||||
virtual ~TabularSchedulableStatisticsWidget();
|
||||
|
||||
void update(const History& changed_history);
|
||||
|
||||
void set_show_runs(bool);
|
||||
bool get_show_runs() const;
|
||||
|
||||
void set_show_perc(bool);
|
||||
bool get_show_perc() const;
|
||||
|
||||
void set_show_inactive(bool);
|
||||
bool get_show_inactive() const;
|
||||
|
||||
void set_show_turn_around(bool);
|
||||
bool get_show_turn_around() const;
|
||||
|
||||
void set_show_response(bool);
|
||||
bool get_show_response() const;
|
||||
|
||||
void set_show_efficency(bool);
|
||||
bool get_show_efficency() const;
|
||||
|
||||
void set_show_resource_usage(bool);
|
||||
bool get_show_resource_usage() const;
|
||||
|
||||
void set_show_resource_block(bool);
|
||||
bool get_show_resource_block() const;
|
||||
|
||||
protected:
|
||||
void update_columns();
|
||||
|
||||
bool _show_runs, //which info to show
|
||||
_show_perc,
|
||||
_show_inactive,
|
||||
_show_turn,
|
||||
_show_resp,
|
||||
_show_effic,
|
||||
_show_ris_usage,
|
||||
_show_ris_block;
|
||||
|
||||
Glib::RefPtr<Gtk::TreeStore> _model; //treeview stuffs
|
||||
Gtk::TreeModelColumnRecord _columns;
|
||||
|
||||
Gtk::TreeModelColumn<Glib::ustring> _col_name; //all columns
|
||||
Gtk::TreeModelColumn<int> _col_runs;
|
||||
Gtk::TreeModelColumn<Glib::ustring> _col_perc;
|
||||
Gtk::TreeModelColumn<int> _col_inactive;
|
||||
Gtk::TreeModelColumn<int> _col_turn;
|
||||
Gtk::TreeModelColumn<Glib::ustring> _col_resp;
|
||||
Gtk::TreeModelColumn<Glib::ustring> _col_effic;
|
||||
Gtk::TreeModelColumn<int> _col_ris_usage;
|
||||
Gtk::TreeModelColumn<int> _col_ris_block;
|
||||
|
||||
};
|
||||
|
||||
} //~ namespace sgpem
|
||||
|
||||
|
||||
#endif
|
|
@ -30,13 +30,6 @@
|
|||
|
||||
#include <cassert>
|
||||
|
||||
//********************** PROVE di STATISTICS
|
||||
#include <iostream>
|
||||
#include "backend/sgpemv2/statistics.hh"
|
||||
#include "backend/thread_statistics.hh"
|
||||
using namespace std;
|
||||
//*************************
|
||||
|
||||
#ifndef NDEBUG
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
@ -134,49 +127,7 @@ SimulationWidget::update(const History& changed_history )
|
|||
_partial_redraw = false;
|
||||
// MOVED in calc_drawing_size(...)
|
||||
// count_elements();
|
||||
resize_redraw();
|
||||
|
||||
|
||||
|
||||
cout << "\n\n****** STATS BEGIN*******\n";
|
||||
|
||||
vector<ProcessStatistics> p_stats = Statistics::get_instance().get_process_statistics(changed_history.get_front());
|
||||
|
||||
cout << "\n INSTANT = " << (int)changed_history.get_front()-1 << "\n\n";
|
||||
|
||||
|
||||
for(int i_p = 0; i_p < p_stats.size(); i_p++)
|
||||
{
|
||||
cout << "\n\n== " << p_stats[i_p].get_core()->get_name().c_str() <<
|
||||
"\t\tRUN= " << p_stats[i_p].get_execution_time() <<
|
||||
"\tPERC= " << p_stats[i_p].get_execution_progress() << "%"<<
|
||||
"\tTURN= " << p_stats[i_p].get_turn_around() <<
|
||||
"\tRISP= " << p_stats[i_p].get_response_time() <<
|
||||
"\t~RISP= " << p_stats[i_p].get_average_response_time() <<
|
||||
"\tEFF= " << p_stats[i_p].get_efficency() << "%" <<
|
||||
"\tINACTIVE= " << p_stats[i_p].get_total_inactivity() <<
|
||||
"\tRIS_USAGE= " << p_stats[i_p].get_resource_usage_time() <<
|
||||
"\tRIS_BLOCK= " << p_stats[i_p].get_resource_waitings_time() ;
|
||||
|
||||
cout << "\n |";
|
||||
|
||||
vector<ThreadStatistics> t_stats = p_stats[i_p].get_threads_statistics();
|
||||
|
||||
for(int i_t = 0; i_t < t_stats.size(); i_t++)
|
||||
cout << "\n |-- " << t_stats[i_t].get_core()->get_name().c_str() <<
|
||||
"\t\tRUN= " << t_stats[i_t].get_execution_time() <<
|
||||
"\tPERC= " << t_stats[i_t].get_execution_progress() << "%" <<
|
||||
"\tINACTIVE= " << t_stats[i_t].get_total_inactivity() <<
|
||||
"\tRISP= " << t_stats[i_t].get_response_time() <<
|
||||
"\tTURN= " << t_stats[i_t].get_turn_around() <<
|
||||
"\tEFF= " << t_stats[i_t].get_efficency() << "%" <<
|
||||
"\tRIS_USAGE= " << t_stats[i_t].get_resource_usage_time() <<
|
||||
"\tRIS_BLOCK= " << t_stats[i_t].get_resource_waitings_time();
|
||||
|
||||
}
|
||||
|
||||
cout << "\n\n****** STATS END*******\n";
|
||||
|
||||
resize_redraw();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
// src/statistics_container_window.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 "statistics_container_window.hh"
|
||||
#include <iostream>
|
||||
|
||||
using namespace sgpem;
|
||||
using namespace std;
|
||||
|
||||
StatisticsContainerWindow::StatisticsContainerWindow()
|
||||
{
|
||||
// This just sets the title of our new window.
|
||||
set_title(_("Simulation Statistics"));
|
||||
_scrolled_tabular.add(_tabular_schedulables_statistics_widget);
|
||||
add(_scrolled_tabular);
|
||||
_scrolled_tabular.show();
|
||||
_tabular_schedulables_statistics_widget.show();
|
||||
|
||||
_scrolled_tabular.get_hscrollbar()->property_visible() = true;
|
||||
_scrolled_tabular.get_vscrollbar()->property_visible() = true;
|
||||
|
||||
//_scrolled_tabular.get_vscrollbar()->set_visible(true);
|
||||
|
||||
/*cout << "\n\nSIIIIIIIIIIIIIIIIIIIII\n\n";
|
||||
if (_scrolled_tabular.get_vscrollbar_visible())
|
||||
cout << "\n\nSIIIIIIIIIIIIIIIIIIIII\n\n";
|
||||
else
|
||||
cout << "\n\nNNNNNNNNNNNNNNNOOOOOOOOOOO\n\n";
|
||||
*/
|
||||
}
|
||||
|
||||
StatisticsContainerWindow::~StatisticsContainerWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
StatisticsContainerWindow::on_size_request(Gtk::Requisition* /* requisition */ )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TabularSchedulableStatisticsWidget&
|
||||
StatisticsContainerWindow::get_tabular_schedulables_statistics_widget()
|
||||
{
|
||||
return _tabular_schedulables_statistics_widget;
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
// src/statistics_container_window.hh - 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
|
||||
|
||||
#ifndef STATISTICS_CONTAINER_WINDOW_HH
|
||||
#define STATISTICS_CONTAINER_WINDOW_HH 1
|
||||
|
||||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#include <gtkmm/window.h>
|
||||
#include <gtkmm/scrolledwindow.h>
|
||||
#include <gtkmm/scrollbar.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
#include <sgpemv2/simulation.hh>
|
||||
#include "schedulables_statistics_widget.hh"
|
||||
|
||||
namespace sgpem {
|
||||
|
||||
|
||||
class StatisticsContainerWindow : public Gtk::Window
|
||||
{
|
||||
public:
|
||||
StatisticsContainerWindow();
|
||||
virtual ~StatisticsContainerWindow();
|
||||
|
||||
TabularSchedulableStatisticsWidget& get_tabular_schedulables_statistics_widget();
|
||||
protected:
|
||||
|
||||
virtual void on_size_request (Gtk::Requisition* requisition);
|
||||
TabularSchedulableStatisticsWidget _tabular_schedulables_statistics_widget;
|
||||
Gtk::ScrolledWindow _scrolled_tabular;
|
||||
};
|
||||
|
||||
} // ~ namespace sgpem
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue