Profiler.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2004 CSIRO ICT Centre
00003  *
00004  * $Id: Profiler.cpp 1809 2006-02-10 15:10:00Z rsc $
00005  */
00006 
00007 #ifdef PROFILE
00008 
00009 #include <iostream>
00010 
00011 #include "Profiler.h"
00012 #include "Timer.h"
00013 
00014 
00015 Profiler::Profiler(String const & name)
00016     : timer(name, Timer::Paused),
00017       maxActiveListSize(0),
00018       numActiveListHits(0),
00019       sumActiveListSize(0)
00020 {
00021 }
00022 
00023 void Profiler::runTimer()
00024 {
00025   timer.cont();
00026 }
00027 
00028 void Profiler::pauseTimer()
00029 {
00030   timer.pause();
00031 }
00032 
00033 void Profiler::registerActiveListSize(unsigned long size)
00034 {
00035   numActiveListHits++;
00036   sumActiveListSize += size;
00037 
00038   if (maxActiveListSize < size)
00039   {
00040     maxActiveListSize = size;
00041   }
00042 }
00043 
00044 void Profiler::outputResults()
00045 {
00046   std::cout << timer;
00047 
00048 #ifdef PROFILE_MEMORY
00049   std::cout << "\n\tmax memory usage: " << timer.max_memory();
00050 #ifdef PROFILE_MEMORY_DETAILS
00051   std::cout << "\n\tshared memory usage: " << timer.shared_memory()
00052             << "\n\tunshared data memory usage: " << timer.unshared_data_memory()
00053             << "\n\tunshared stack memory usage: " << timer.unshared_stack_memory();
00054 #endif
00055 #endif
00056 
00057 #ifdef PROFILE_PAGE_FAULTS
00058   std::cout << "\n\tpage faults: " << timer.page_faults();
00059 #ifdef PROFILE_PAGE_FAULT_DETAILS
00060   std::cout << "\n\tminor page faults: " << timer.minor_page_faults();
00061   std::cout << "\n\tmajor page faults: " << timer.major_page_faults();
00062 #endif
00063 #endif
00064 
00065 #ifdef PROFILE_BLOCKED_IO
00066   std::cout << "\n\tblocked input operations: " << timer.blocked_input_ops();
00067   std::cout << "\n\tblocked output operations: " << timer.blocked_output_ops();
00068 #endif
00069 
00070 #ifdef PROFILE_ACTIVE_LIST
00071   unsigned long long meanActiveListSize = (numActiveListHits == 0) ? 0 : sumActiveListSize / numActiveListHits;
00072 
00073 #ifndef SILENT
00074   std::cout << "\n\tmean active list size: " << meanActiveListSize
00075             << "\n\tmax active list size: " << maxActiveListSize;
00076 #endif
00077 #endif // ifdef PROFILE_ACTIVE_LIST
00078 
00079   std::cout << ".\n";
00080 }
00081 
00082 #endif // ifdef PROFILE
Generated on Mon Oct 4 10:39:55 2010 for Matching.kdevelop by  doxygen 1.6.3