Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages | Examples

ac_stats.cpp

00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 
00003 /*  ArchC Statistics Library for the ArchC architecture simulators
00004     Copyright (C) 2002-2004  The ArchC Team
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Lesser General Public
00008     License as published by the Free Software Foundation; either
00009     version 2.1 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Lesser General Public License for more details.
00015 */
00016 
00017 /********************************************************/
00018 /* Statistics class                                     */
00019 /* Author:  Sandro Rigo                                 */
00020 /*                                                      */
00021 /*                                                      */
00022 /* The ArchC Team                                       */
00023 /* Computer Systems Laboratory (LSC)                    */
00024 /* IC-UNICAMP                                           */
00025 /* http://www.lsc.ic.unicamp.br                         */
00026 /********************************************************/
00027  
00028 
00029 #include  "ac_stats.H"
00030 #include "ac_types.H"
00031 
00032 
00034 ac_stats::ac_stats():INIT_STO_STATS{
00035 
00036   int i;
00038   for( i = 0; i<= AC_DEC_INSTR_NUMBER; i++)
00039     instr_table[i][0] = instr_table[i][1] = instr_table[i][2]= 0;
00040 
00041   instr_executed = 0;
00042   init_stat();
00043 }
00044 
00045 
00046 
00048 void ac_stats::print( ){
00049 
00050   int i;
00051 
00052   ac_sto_stats *pstats;
00053 
00054   output << flush;
00055   output << "********************************************" << endl;
00056   output << "*    ArchC Simulation Statistics Report    *" << endl;
00057   output << "********************************************" << endl;
00058 
00059   output << endl;
00060 
00061   output << "Simulation time: " << time << endl;
00062   output << "Total of Executed Instructions: " << instr_executed << endl;
00063 
00064   output << endl;
00065 
00066 #ifdef AC_CYCLE_RANGE
00067   output << "Cycle count estimates "<< endl;
00068   output << "Minimum number of cycles: " << ac_min_cycle_count << endl;
00069   output << "Maximum number of cycles: " << ac_max_cycle_count << endl;
00070 
00071   output << endl;
00072 #endif
00073 
00074   output << "=> Instruction Set Statistics: " << endl << endl;
00075 
00076   for( i =1; i<= AC_DEC_INSTR_NUMBER; i++) {
00077 
00078     if( instr_table[i][2] ){
00079       output << ((ac_instruction *)instr_table[i][1])->get_name();
00080       output << " was executed " << instr_table[i][2] << " times." << endl;
00081     }
00082   }
00083   output << endl;
00084 
00085   output << "=> Storage Statistics: " << endl << endl;
00086 
00087   for ( pstats = head; pstats != NULL; pstats = pstats->next ){
00088 
00089     output << "Device " << pstats->get_name() << " was accessed " << pstats->get_accesses() << " times";
00090 
00091     if( pstats->get_misses() )
00092       {
00093         output << " and had " << pstats->get_misses() << " misses. " ;
00094         output.setf(ios::fixed);
00095         output.precision(2);
00096         output << "(Miss Rate: " << (float)100*pstats->get_misses()/pstats->get_accesses() << "%)" << endl;
00097       }
00098     else
00099       output << "." << endl;
00100   }
00101 
00102   
00103 };

Generated on Thu Jun 24 08:30:05 2004 for ArchC by doxygen 1.3.4