added statistics show/hide, resized windows, added, scrolbars, added

simulation statistics 


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1141 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
fpaparel 2006-09-14 10:58:54 +00:00
parent 290360c3b0
commit 03498c1a78
8 changed files with 299 additions and 31 deletions

View File

@ -349,6 +349,7 @@ sgpemv2_SOURCES = \
src/schedulables_statistics_widget.cc \ src/schedulables_statistics_widget.cc \
src/schedulables_tree_widget.cc \ src/schedulables_tree_widget.cc \
src/simulation_controller.cc \ src/simulation_controller.cc \
src/simulation_statistics_widget.cc \
src/simulation_widget.cc \ src/simulation_widget.cc \
src/statistics_container_window.cc \ src/statistics_container_window.cc \
src/text_simulation.cc src/text_simulation.cc
@ -371,6 +372,7 @@ noinst_HEADERS += \
src/schedulables_statistics_widget.hh \ src/schedulables_statistics_widget.hh \
src/schedulables_tree_widget.hh \ src/schedulables_tree_widget.hh \
src/simulation_controller.hh \ src/simulation_controller.hh \
src/simulation_statistics_widget.hh \
src/simulation_widget.hh \ src/simulation_widget.hh \
src/schedulables_statistics_widget.hh \ src/schedulables_statistics_widget.hh \
src/text_simulation.hh src/text_simulation.hh
@ -385,7 +387,8 @@ glade_DATA = \
glade/add-thread-dialog.glade \ glade/add-thread-dialog.glade \
glade/configure-dialog.glade \ glade/configure-dialog.glade \
glade/jump-to-dialog.glade \ glade/jump-to-dialog.glade \
glade/main-window.glade glade/main-window.glade \
glade/statistics-window.glade
EXTRA_DIST += $(glade_DATA) EXTRA_DIST += $(glade_DATA)

View File

@ -29,6 +29,7 @@
#include "holt_widget.hh" #include "holt_widget.hh"
#include "ready_queue_widget.hh" #include "ready_queue_widget.hh"
#include "schedulables_tree_widget.hh" #include "schedulables_tree_widget.hh"
#include "schedulables_statistics_widget.hh"
#include "simulation_widget.hh" #include "simulation_widget.hh"
#include "resources_widget.hh" #include "resources_widget.hh"
#include "jump_to_dialog.hh" #include "jump_to_dialog.hh"
@ -64,6 +65,7 @@
#include <gtkmm/spinbutton.h> #include <gtkmm/spinbutton.h>
#include <gtkmm/statusbar.h> #include <gtkmm/statusbar.h>
#include <gtkmm/stock.h> #include <gtkmm/stock.h>
#include <gtkmm/window.h>
#include <cassert> #include <cassert>
#include <iostream> #include <iostream>
@ -122,6 +124,20 @@ GuiBuilder::on_view_show_holt_graph_activate()
} }
} }
void
GuiBuilder::on_view_show_statistics_activate()
{
if(_statistics_container.get_main_window()->is_visible())
{
_statistics_container.get_main_window()->hide();
}
else
{
_statistics_container.get_main_window()->show();
}
}
void void
GuiBuilder::on_file_new_activate() GuiBuilder::on_file_new_activate()
@ -565,6 +581,10 @@ GuiBuilder::GuiBuilder(const std::string& gladefile)
_refXml->get_widget("MenuItem.View.ShowHoltGraph", show_holt_graph); _refXml->get_widget("MenuItem.View.ShowHoltGraph", show_holt_graph);
show_holt_graph->signal_activate().connect(sigc::mem_fun(*this, &GuiBuilder::on_view_show_holt_graph_activate)); show_holt_graph->signal_activate().connect(sigc::mem_fun(*this, &GuiBuilder::on_view_show_holt_graph_activate));
// show/hide statistics window
MenuItem* show_statistics_graph;
_refXml->get_widget("MenuItem.View.ShowStatistics", show_statistics_graph);
show_statistics_graph->signal_activate().connect(sigc::mem_fun(*this, &GuiBuilder::on_view_show_statistics_activate));
CheckMenuItem* continuous_mode; CheckMenuItem* continuous_mode;
@ -656,9 +676,20 @@ GuiBuilder::GuiBuilder(const std::string& gladefile)
_holt_container.get_holt_widget().set_show_threads(_show_threads); _holt_container.get_holt_widget().set_show_threads(_show_threads);
_holt_container.show(); _holt_container.show();
// Statistics container window _statistics_container.get_main_window()->set_transient_for(main_window);
_statistics_container.set_transient_for(main_window);
_statistics_container.show(); // Moves and resize windows
int w = gdk_screen_width(), h= gdk_screen_height();;
get_initial_window().move(0,0);
get_initial_window().resize(w,(h/3)*2 - 50);
_holt_container.move(0, (h/3)*2);
_holt_container.resize(h/3, h/3);
_statistics_container.get_main_window()->move(h/3 + 15,(h/3)*2);
_statistics_container.get_main_window()->resize(w - h/3 - 15, h/3);
} }

View File

@ -62,6 +62,7 @@ namespace sgpem
void on_view_show_threads_activate(); void on_view_show_threads_activate();
void on_view_show_holt_graph_activate(); void on_view_show_holt_graph_activate();
void on_view_show_statistics_activate();
void on_configure_cpu_policy(); void on_configure_cpu_policy();
void on_configure_resource_policy(); void on_configure_resource_policy();

View File

@ -136,17 +136,6 @@ TabularSchedulableStatisticsWidget::update(const History& changed_history)
} }
} }
expand_all(); 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,133 @@
// src/simulation_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 "simulation_statistics_widget.hh"
#include <sgpemv2/simulation.hh>
#include <sgpemv2/history.hh>
#include <sgpemv2/statistics.hh>
#include <iostream>
#include <stdio.h> //per sprintf
using namespace sgpem;
using namespace std;
using namespace Gtk;
using namespace Glib;
TabularSimulationStatisticsWidget::TabularSimulationStatisticsWidget()
{
//insert columns
_columns.add(_col_inactivity);
_columns.add(_col_progress);
_columns.add(_col_turn);
_columns.add(_col_response);
_columns.add(_col_effic);
_columns.add(_col_term_procs);
_columns.add(_col_term_threads);
_columns.add(_col_through_procs);
_columns.add(_col_through_threads);
_model = TreeStore::create(_columns);
set_model(_model);
append_column(_("Avg. inactivity time"), _col_inactivity);
append_column(_("Avg. execution progress"), _col_progress);
append_column(_("Avg. turn around"), _col_turn);
append_column(_("Avg. response time"), _col_response);
append_column(_("Avg. efficiency"), _col_effic);
append_column(_("# terminated processes"), _col_term_procs);
append_column(_("# terminated threads"), _col_term_threads);
append_column(_("Avg. processes throughput"), _col_through_procs);
append_column(_("Avg. threads throughput"), _col_through_threads);
set_headers_visible(true);
// Register this HistoryObserver:
Simulation::get_instance().get_history().attach(*this);
}
TabularSimulationStatisticsWidget::~TabularSimulationStatisticsWidget()
{
Simulation::get_instance().get_history().detach(*this);
}
void
TabularSimulationStatisticsWidget::update(const History& changed_history)
{
_model->clear();
int num_procs=0, num_threads=0;
vector<Process*> procs = Simulation::get_instance().get_history().get_environment_at(0).get_processes();
num_procs = procs.size();
for (uint i =0; i < procs.size(); i++)
num_threads += procs[i]->get_threads().size();
if (num_procs == 0)
return;
Statistics::get_instance().calculateStatisticsAt(changed_history.get_front());
const SimulationStatistics* stats = Statistics::get_instance().get_simulation_statistics();
TreeModel::Row riga_P = *(_model->append());
char buff[100];
sprintf(buff, "%.2f", stats->get_average_inactivity_time());
riga_P[_col_inactivity] = Glib::ustring(buff);
sprintf(buff, "%.1f", stats->get_average_execution_progress());
riga_P[_col_progress] = Glib::ustring(buff) + Glib::ustring("%");
sprintf(buff, "%.2f", stats->get_average_turn_around());
riga_P[_col_turn] = Glib::ustring(buff);
sprintf(buff, "%.2f", stats->get_average_response_time());
riga_P[_col_response] = Glib::ustring(buff);
sprintf(buff, "%.1f", stats->get_average_efficiency());
riga_P[_col_effic] = Glib::ustring(buff) + Glib::ustring("%");
sprintf(buff, "%d / %d", stats->get_terminated_processes(), num_procs);
riga_P[_col_term_procs] = Glib::ustring(buff);
sprintf(buff, "%d / %d", stats->get_terminated_threads(), num_threads);
riga_P[_col_term_threads] = Glib::ustring(buff);
sprintf(buff, "%.3f", stats->get_average_processes_throughput());
riga_P[_col_through_procs] = Glib::ustring(buff);
sprintf(buff, "%.3f", stats->get_average_threads_throughput());
riga_P[_col_through_threads]= Glib::ustring(buff);
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,65 @@
// src/simulation_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 SIMULATION_STATISTICS_WIDGET_HH
#define SIMULATION_STATISTICS_WIDGET_HH 1
#include "config.h"
#include <sgpemv2/history_observer.hh>
#include <gtkmm/treeview.h>
#include <gtkmm/treestore.h>
namespace sgpem
{
class TabularSimulationStatisticsWidget : public HistoryObserver, public Gtk::TreeView
{
public:
TabularSimulationStatisticsWidget();
virtual ~TabularSimulationStatisticsWidget();
void update(const History& changed_history);
protected:
Glib::RefPtr<Gtk::TreeStore> _model; //treeview stuffs
Gtk::TreeModelColumnRecord _columns;
Gtk::TreeModelColumn<Glib::ustring> _col_inactivity; //all columns
Gtk::TreeModelColumn<Glib::ustring> _col_progress;
Gtk::TreeModelColumn<Glib::ustring> _col_turn;
Gtk::TreeModelColumn<Glib::ustring> _col_response;
Gtk::TreeModelColumn<Glib::ustring> _col_effic;
Gtk::TreeModelColumn<Glib::ustring> _col_term_procs;
Gtk::TreeModelColumn<Glib::ustring> _col_term_threads;
Gtk::TreeModelColumn<Glib::ustring> _col_through_procs;
Gtk::TreeModelColumn<Glib::ustring> _col_through_threads;
};
} //~ namespace sgpem
#endif

View File

@ -19,17 +19,44 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "statistics_container_window.hh" #include "statistics_container_window.hh"
#include <glibmm/ustring.h>
#include <iostream> #include <iostream>
using namespace Gtk;
using Gnome::Glade::Xml;
using namespace sgpem; using namespace sgpem;
using namespace std; using namespace std;
StatisticsContainerWindow::StatisticsContainerWindow() StatisticsContainerWindow::StatisticsContainerWindow(const std::string& gladefile)
: _refXml(Xml::create(gladefile))
{ {
_refXml->get_widget("StatisticsWindow", _main_win);
// This just sets the title of our new window. // This just sets the title of our new window.
set_title(_("Simulation Statistics")); _main_win->set_title(_("Simulation Statistics"));
set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
ScrolledWindow *scroll1, *scroll2;
_refXml->get_widget("SchedulableStatisticsScroll", scroll1);
_tab_sched = manage(new TabularSchedulableStatisticsWidget());
scroll1->add(*_tab_sched);
_refXml->get_widget("SimulationStatisticsScroll", scroll2);
_tab_sim = manage(new TabularSimulationStatisticsWidget());
scroll2->add(*_tab_sim);
_main_win->show();
scroll1->show();
scroll2->show();
_tab_sched->show();
_tab_sim->show();
_main_win->set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
/*
_scrolled_tabular.add(_tabular_schedulables_statistics_widget); _scrolled_tabular.add(_tabular_schedulables_statistics_widget);
add(_scrolled_tabular); add(_scrolled_tabular);
_scrolled_tabular.show(); _scrolled_tabular.show();
@ -37,7 +64,7 @@ StatisticsContainerWindow::StatisticsContainerWindow()
_scrolled_tabular.get_hscrollbar()->property_visible() = true; _scrolled_tabular.get_hscrollbar()->property_visible() = true;
_scrolled_tabular.get_vscrollbar()->property_visible() = true; _scrolled_tabular.get_vscrollbar()->property_visible() = true;
*/
//_scrolled_tabular.get_vscrollbar()->set_visible(true); //_scrolled_tabular.get_vscrollbar()->set_visible(true);
/*cout << "\n\nSIIIIIIIIIIIIIIIIIIIII\n\n"; /*cout << "\n\nSIIIIIIIIIIIIIIIIIIIII\n\n";
@ -51,16 +78,28 @@ StatisticsContainerWindow::StatisticsContainerWindow()
StatisticsContainerWindow::~StatisticsContainerWindow() StatisticsContainerWindow::~StatisticsContainerWindow()
{ {
} }
void
StatisticsContainerWindow::on_size_request(Gtk::Requisition* /* requisition */ )
{
void
StatisticsContainerWindow::make_child(Window& w)
{
_main_win->set_transient_for(w);
} }
TabularSchedulableStatisticsWidget& TabularSimulationStatisticsWidget*
StatisticsContainerWindow::get_tabular_simulation_statistics_widget()
{
return _tab_sim;
}
TabularSchedulableStatisticsWidget*
StatisticsContainerWindow::get_tabular_schedulables_statistics_widget() StatisticsContainerWindow::get_tabular_schedulables_statistics_widget()
{ {
return _tabular_schedulables_statistics_widget; return _tab_sched;
}
Window*
StatisticsContainerWindow::get_main_window()
{
return _main_win;
} }

View File

@ -27,28 +27,35 @@
#include <gtkmm/window.h> #include <gtkmm/window.h>
#include <gtkmm/scrolledwindow.h> #include <gtkmm/scrolledwindow.h>
#include <gtkmm/scrollbar.h> #include <gtkmm/scrollbar.h>
#include <libglademm/xml.h>
#include <cassert> #include <cassert>
#include <iostream> #include <iostream>
#include <sgpemv2/simulation.hh> #include <sgpemv2/simulation.hh>
#include "schedulables_statistics_widget.hh" #include "schedulables_statistics_widget.hh"
#include "simulation_statistics_widget.hh"
namespace sgpem { namespace sgpem {
class StatisticsContainerWindow : public Gtk::Window class StatisticsContainerWindow
{ {
public: public:
StatisticsContainerWindow(); StatisticsContainerWindow(const std::string& gladefile = GLADEDIR "/statistics-window.glade");
virtual ~StatisticsContainerWindow(); virtual ~StatisticsContainerWindow();
TabularSchedulableStatisticsWidget& get_tabular_schedulables_statistics_widget(); void make_child(Gtk::Window&);
TabularSchedulableStatisticsWidget* get_tabular_schedulables_statistics_widget();
TabularSimulationStatisticsWidget* get_tabular_simulation_statistics_widget();
Gtk::Window* get_main_window();
protected: protected:
virtual void on_size_request (Gtk::Requisition* requisition); Glib::RefPtr<Gnome::Glade::Xml> _refXml;
TabularSchedulableStatisticsWidget _tabular_schedulables_statistics_widget; Gtk::Window* _main_win;
Gtk::ScrolledWindow _scrolled_tabular; TabularSchedulableStatisticsWidget* _tab_sched;
TabularSimulationStatisticsWidget* _tab_sim;
}; };
} // ~ namespace sgpem } // ~ namespace sgpem