00001 // stats.h 00002 // Routines for managing statistics about Nachos performance. 00003 // 00004 // DO NOT CHANGE -- these stats are maintained by the machine emulation. 00005 // 00006 // Copyright (c) 1992-1996 The Regents of the University of California. 00007 // All rights reserved. See copyright.h for copyright notice and limitation 00008 // of liability and disclaimer of warranty provisions. 00009 00010 #include "copyright.h" 00011 #include "debug.h" 00012 #include "stats.h" 00013 00014 //---------------------------------------------------------------------- 00015 // Statistics::Statistics 00016 // Initialize performance metrics to zero, at system startup. 00017 //---------------------------------------------------------------------- 00018 00019 Statistics::Statistics() 00020 { 00021 totalTicks = idleTicks = systemTicks = userTicks = 0; 00022 numDiskReads = numDiskWrites = 0; 00023 numConsoleCharsRead = numConsoleCharsWritten = 0; 00024 numPageFaults = numPacketsSent = numPacketsRecvd = 0; 00025 } 00026 00027 //---------------------------------------------------------------------- 00028 // Statistics::Print 00029 // Print performance metrics, when we've finished everything 00030 // at system shutdown. 00031 //---------------------------------------------------------------------- 00032 00033 void 00034 Statistics::Print() 00035 { 00036 cerr << "Ticks: total " << totalTicks << ", idle " << idleTicks; 00037 cerr << ", system " << systemTicks << ", user " << userTicks <<"\n"; 00038 cerr << "Disk I/O: reads " << numDiskReads; 00039 cerr << ", writes " << numDiskWrites << "\n"; 00040 cerr << "Console I/O: reads " << numConsoleCharsRead; 00041 cerr << ", writes " << numConsoleCharsWritten << "\n"; 00042 cerr << "Paging: faults " << numPageFaults << "\n"; 00043 cerr << "Network I/O: packets received " << numPacketsRecvd; 00044 cerr << ", sent " << numPacketsSent << "\n"; 00045 }