test fo the statistic calculus --gv
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1236 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
859df07a89
commit
1569165eb7
|
@ -0,0 +1,198 @@
|
|||
// src/testsuite/test-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
|
||||
|
||||
/* This executable tests to check if the calculus for the statistics are exact,
|
||||
* and nothing else. */
|
||||
|
||||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#include <glibmm/ustring.h>
|
||||
|
||||
#include<vector>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
#include <sgpemv2/simulation.hh>
|
||||
#include <sgpemv2/cpu_policies_gatekeeper.hh>
|
||||
#include <sgpemv2/cpu_policy_manager.hh>
|
||||
#include <sgpemv2/cpu_policy.hh>
|
||||
#include <sgpemv2/statistics.hh>
|
||||
#include <sgpemv2/process_statistics.hh>
|
||||
#include <sgpemv2/thread_statistics.hh>
|
||||
|
||||
using namespace sgpem;
|
||||
using namespace std;
|
||||
using Glib::ustring;
|
||||
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
ostream& info = cout;
|
||||
ostream& test = cerr;
|
||||
|
||||
using namespace sgpem;
|
||||
|
||||
Simulation& sim=Simulation::get_instance();
|
||||
|
||||
History& hi=sim.get_history();
|
||||
|
||||
Process& pz1=hi.add_process("P1",0,2);
|
||||
hi.add_thread("T1",pz1,3,0,2);
|
||||
|
||||
Process& pz2=hi.add_process("P2",1,3);
|
||||
hi.add_thread("T2",pz2,7,1,3);
|
||||
|
||||
Process& pz3=hi.add_process("P3",3,5);
|
||||
hi.add_thread("T3",pz3,4,3,5);
|
||||
|
||||
Process& pz4=hi.add_process("P4",5,3);
|
||||
hi.add_thread("T4",pz4,6,5,4);
|
||||
|
||||
Process& pz5=hi.add_process("P5",8,2);
|
||||
hi.add_thread("T5",pz5,2,8,2);
|
||||
|
||||
cout<<sim.get_mode();
|
||||
|
||||
|
||||
typedef CPUPoliciesGatekeeper::Managers ManagerVec;
|
||||
typedef CPUPoliciesGatekeeper::Manager::Policies PolicyVec;
|
||||
|
||||
ManagerVec managers = CPUPoliciesGatekeeper::get_instance().get_registered();
|
||||
PolicyVec policies = managers[0]->get_avail_policies();
|
||||
CPUPolicy* p=policies[0];
|
||||
sim.set_policy(p);
|
||||
sim.run();
|
||||
|
||||
|
||||
info << "Simulation Started\n";
|
||||
info<<"Starting to test the statistics claculus regarding the simulation\n";
|
||||
|
||||
Statistics::get_instance().calculateStatisticsAt(22);
|
||||
|
||||
const SimulationStatistics* stats = Statistics::get_instance().get_simulation_statistics();
|
||||
info << "Checking simulation statisics... ";
|
||||
test<<"Checking method get_average_inactivity_time()";
|
||||
if(stats->get_average_inactivity_time()==6.00)
|
||||
test<<"PASS \n";
|
||||
else
|
||||
test<<"FAIL \n";
|
||||
|
||||
test<<"Checking method get_average_turn_around()";
|
||||
if(stats->get_average_turn_around()==10.40)
|
||||
test<<"PASS \n";
|
||||
else
|
||||
test<<"FAIL \n";
|
||||
|
||||
test<<"Checking method get_average_response_time()";
|
||||
if(stats->get_average_response_time()==6.00)
|
||||
test<<"PASS \n";
|
||||
else
|
||||
test<<"FAIL \n";
|
||||
|
||||
test<<"Checking method get_terminated_processes()";
|
||||
if(stats->get_terminated_processes()==5)
|
||||
test<<"PASS \n";
|
||||
else
|
||||
test<<"FAIL \n";
|
||||
|
||||
test<<"Checking method get_terminated_threads()";
|
||||
if(stats->get_terminated_threads()==5)
|
||||
test<<"PASS \n";
|
||||
else
|
||||
test<<"FAIL \n";
|
||||
|
||||
|
||||
info<<"Checking process statistics.........";
|
||||
|
||||
const std::vector<const ProcessStatistics*> procs=Statistics::get_instance().get_process_statistics();
|
||||
test<<"Checking method get_execution_time()";
|
||||
if(procs[0]->get_execution_time()==3)
|
||||
test<<"PASS \n";
|
||||
else
|
||||
test<<"FAIL \n";
|
||||
|
||||
test<<"Checking get_total_inactivity()";
|
||||
if(procs[1]->get_total_inactivity()==2)
|
||||
test<<"PASS \n";
|
||||
else
|
||||
test<<"FAIL \n";
|
||||
|
||||
test<<"Checking get_response_time()";
|
||||
if(procs[2]->get_response_time()==7)
|
||||
test<<"PASS \n";
|
||||
else
|
||||
test<<"FAIL \n";
|
||||
|
||||
test<<"Checking get_average_response_time()";
|
||||
if(procs[2]->get_response_time()==7)
|
||||
test<<"PASS \n";
|
||||
else
|
||||
test<<"FAIL \n";
|
||||
|
||||
test<<"Checking get_turn_around()";
|
||||
if(procs[5]->get_turn_around()==14)
|
||||
test<<"PASS \n";
|
||||
else
|
||||
test<<"FAIL \n";
|
||||
|
||||
test<<"Checking get_resource_usage_time()";
|
||||
if(procs[3]->get_turn_around()==0)
|
||||
test<<"PASS \n";
|
||||
else
|
||||
test<<"FAIL \n";
|
||||
|
||||
|
||||
|
||||
info<<"Starting to check thread statistics of the process P2....";
|
||||
const std::vector<const ThreadStatistics*> thstat=procs[1]->get_threads_statistics();
|
||||
|
||||
test<<"Checking get_threads_statistics()";
|
||||
if(thstat.size()==1)
|
||||
test<<"PASS \n";
|
||||
else
|
||||
test<<"FAIL \n";
|
||||
|
||||
test<<"Checking get_execution_time()";
|
||||
if(thstat[0]->get_execution_time()==7)
|
||||
test<<"PASS \n";
|
||||
else
|
||||
test<<"FAIL \n";
|
||||
|
||||
test<<"Checking get_response_time()";
|
||||
if(thstat[0]->get_response_time()==2)
|
||||
test<<"PASS \n";
|
||||
else
|
||||
test<<"FAIL \n";
|
||||
|
||||
|
||||
test<<"Checking get_turn_around()";
|
||||
if(thstat[0]->get_turn_around()==9)
|
||||
test<<"PASS \n";
|
||||
else
|
||||
test<<"FAIL \n";
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue