diff --git a/doc/sgpem2uman.texi b/doc/sgpem2uman.texi index dae9ce4..e21d05d 100644 --- a/doc/sgpem2uman.texi +++ b/doc/sgpem2uman.texi @@ -1062,6 +1062,8 @@ Syntax depends from entities being displayed: With being the numeric identifier of the thread child of process identified by @item @command{show subrequests } Where the numeric ids follow the same logic of the previous commands + @item @command{show statistics} + Shows statistics for the whole simulation for the current instant @end itemize @item @command{add} diff --git a/src/text_simulation.cc b/src/text_simulation.cc index 328c9e1..102b7b3 100644 --- a/src/text_simulation.cc +++ b/src/text_simulation.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include @@ -677,7 +678,8 @@ TextSimulation::on_help(const Tokens& arguments) "`SHOW requests ` with being the numeric " "identifier of the thread child of process identified by \n" "`SHOW subrequests ` where the numeric ids " - "follow the same logic of the previous commands\n")); + "follow the same logic of the previous commands\n" + "`SHOW statistics`\n")); else if (command == "ADD") p_stderr(_("-- ADD COMMAND --\nAdds an entity by using a questionary-like approach.\n\n" "Syntax depends from entity being added:\n" @@ -904,6 +906,7 @@ TextSimulation::on_show(const Tokens& arguments) entities_handlers["SUBREQUESTS"] = &TextSimulation::on_show_subrequests; entities_handlers["CPU-POLICIES"] = &TextSimulation::on_show_cpu_policies; entities_handlers["RESOURCE-POLICIES"] = &TextSimulation::on_show_resource_policies; + entities_handlers["STATISTICS"] = &TextSimulation::on_show_statistics; if (entities_handlers.find(entities) == entities_handlers.end()) p_stderr(_("ERROR: invalid argument\n")); @@ -1079,6 +1082,30 @@ TextSimulation::on_show_resource_policies(const Tokens& arguments) show_policies(arguments); } +void +TextSimulation::on_show_statistics(const Tokens& arguments) +{ + check_arguments_num(arguments, 0); + + unsigned int front = Simulation::get_instance().get_history().get_front(); + Statistics::get_instance().calculateStatisticsAt(front); + const SimulationStatistics* sim = Statistics::get_instance().get_simulation_statistics(); + + ostringstream oss; + + oss << "\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"; + + p_stdout(oss.str()); +} + void TextSimulation::on_add(const Tokens& arguments) { diff --git a/src/text_simulation.hh b/src/text_simulation.hh index ad93460..36192a3 100644 --- a/src/text_simulation.hh +++ b/src/text_simulation.hh @@ -97,6 +97,7 @@ namespace sgpem void on_show_subrequests(const Tokens& arguments); void on_show_cpu_policies(const Tokens& arguments); void on_show_resource_policies(const Tokens& arguments); + void on_show_statistics(const Tokens& arguments); void on_add(const Tokens& arguments); void on_add_process(const Tokens& arguments); void on_add_resource(const Tokens& arguments); @@ -112,8 +113,6 @@ namespace sgpem void on_save(const Tokens& arguments); void on_load(const Tokens& arguments); - // FIXME This is a temporary replacement for the - // to-be written I/O layer static void p_stdout(const Glib::ustring& str); static void p_stderr(const Glib::ustring& str); static Glib::ustring readline();