Changeset 7025
- Timestamp:
- Oct 12, 2001, 2:49:51 AM (24 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/include/perfview.h ¶
r7010 r7025 1 /* $Id: perfview.h,v 1. 1 2001-10-11 00:59:59phaller Exp $ */1 /* $Id: perfview.h,v 1.2 2001-10-12 00:49:51 phaller Exp $ */ 2 2 3 3 /* … … 18 18 extern "C" { 19 19 #endif 20 20 21 22 // calibrate the subsystem 23 void _Optlink PerfView_Initialize(void); 21 24 22 25 // register a call to a function -
TabularUnified trunk/src/kernel32/perfview.cpp ¶
r7021 r7025 1 /* $Id: perfview.cpp,v 1. 1 2001-10-11 17:31:12phaller Exp $ */1 /* $Id: perfview.cpp,v 1.2 2001-10-12 00:49:24 phaller Exp $ */ 2 2 3 3 /* … … 18 18 19 19 // insert "nullified" dummies here to save space in the executable image 20 void PerfView_Initialize(void) {} 20 21 void PerfView_RegisterCall(char* pszFunctionName, 21 22 unsigned long int nTicks) {} … … 27 28 28 29 #include <ccollection.h> 29 #include <win 32type.h>30 #include <winbase.h> 30 31 31 32 // imported from the kernel loader (initterm) … … 40 41 unsigned long int nCalled; 41 42 unsigned long int nTotalTicks; 43 unsigned long int nMinimumTicks; 44 unsigned long int nMaximumTicks; 42 45 } PERFVIEW_FUNCTION, *PPERFVIEW_FUNCTION; 43 46 … … 46 49 static CHashtableLookup* pProfileMap = new CHashtableLookup(1021); 47 50 static BOOL flagLock = FALSE; 51 static unsigned long int tsCompensation = 0; 52 53 54 // measure the measurement overhead itself 55 void PerfView_Initialize(void) 56 { 57 #define CALIBRATION_RUNS 100 58 59 LARGE_INTEGER liStart; 60 LARGE_INTEGER liEnd; 61 unsigned long ulElapsed; 62 63 // initialize this 64 tsCompensation = 0; 65 66 for (int i = 0; 67 i < CALIBRATION_RUNS; 68 i++) 69 { 70 QueryPerformanceCounter(&liStart); 71 QueryPerformanceCounter(&liEnd); 72 73 if (liStart.LowPart > liEnd.LowPart) 74 ulElapsed = 0xFFFFFFFF - liStart.LowPart + liEnd.LowPart; 75 else 76 ulElapsed = liEnd.LowPart - liStart.LowPart; 77 78 // save the determined amount of elapsed ticks 79 // as compensatory factor 80 tsCompensation += ulElapsed; 81 } 82 83 // now calculate back to real value 84 tsCompensation /= CALIBRATION_RUNS; 85 } 86 48 87 49 88 // register a call to a function … … 54 93 if (flagLock) 55 94 return; 95 96 // subtract the measurement overhead factor. 97 // Note: this should rather be done where the times are taken, 98 // however this would spread the code just too far. 99 nTicks -= tsCompensation; 56 100 57 101 // check if that particular function is registered already … … 64 108 p->nCalled = 0; 65 109 p->nTotalTicks = 0; 110 p->nMinimumTicks = 0xffffffff; 111 p->nMaximumTicks = 0; 66 112 67 113 // add to the hashtable … … 72 118 p->nCalled++; 73 119 p->nTotalTicks += nTicks; 120 121 if (nTicks < p->nMinimumTicks) 122 p->nMinimumTicks = nTicks; 123 124 if (nTicks > p->nMaximumTicks) 125 p->nMaximumTicks = nTicks; 74 126 } 75 127 … … 134 186 PHASHTABLEENTRY arrEntries = (PHASHTABLEENTRY)malloc( iEntries * sizeof(HASHTABLEENTRY) ); 135 187 iEntries = pProfileMap->getElementMap(arrEntries); 188 189 fprintf(file, 190 "ODIN Performance Analysis\n" 191 "%d entries available, compensated measure overhead is %d ticks.\n\n", 192 iEntries, 193 tsCompensation); 194 136 195 137 196 // sort the list by function name … … 144 203 fprintf(file, 145 204 "Sorted by function name\n" 205 "Ticks ---- Called --- Average -- Minimum -- Maximum -- Function -----------\n"); 206 for(int i = 0; 207 i < iEntries; 208 i++) 209 { 210 PPERFVIEW_FUNCTION p = (PPERFVIEW_FUNCTION)arrEntries[i].pObject; 211 fprintf(file, 212 "%10d %10d %10d %10d %10d %s\n", 213 p->nTotalTicks, 214 p->nCalled, 215 p->nTotalTicks / p->nCalled, 216 p->nMinimumTicks, 217 p->nMaximumTicks, 218 p->pszFunctionName); 219 } 220 221 222 // sort the list by nTotalTicks 223 qsort(arrEntries, 224 iEntries, 225 sizeof( HASHTABLEENTRY ), 226 sortHashtableEntries1); 227 228 // write to file 229 fprintf(file, 230 "\nSorted by total call time\n" 146 231 "Ticks ---- Called --- Average -- Function ---------------------------------\n"); 147 for(i nt i= 0;232 for(i = 0; 148 233 i < iEntries; 149 234 i++) … … 159 244 160 245 161 // sort the list by nTotalTicks162 qsort(arrEntries,163 iEntries,164 sizeof( HASHTABLEENTRY ),165 sortHashtableEntries1);166 167 // write to file168 fprintf(file,169 "\nSorted by total call time\n"170 "Ticks ---- Called --- Average -- Function ---------------------------------\n");171 for(i = 0;172 i < iEntries;173 i++)174 {175 PPERFVIEW_FUNCTION p = (PPERFVIEW_FUNCTION)arrEntries[i].pObject;176 fprintf(file,177 "%10d %10d %10d %s\n",178 p->nTotalTicks,179 p->nCalled,180 p->nTotalTicks / p->nCalled,181 p->pszFunctionName);182 }183 184 185 246 // sort the list by nCalled 186 247 qsort(arrEntries, -
TabularUnified trunk/src/kernel32/winexepeldr.cpp ¶
r5262 r7025 1 /* $Id: winexepeldr.cpp,v 1.1 5 2001-02-24 12:59:44 sandervlExp $ */1 /* $Id: winexepeldr.cpp,v 1.16 2001-10-12 00:49:23 phaller Exp $ */ 2 2 3 3 /* … … 39 39 #define DBG_LOCALLOG DBG_winexepeldr 40 40 #include "dbglocal.h" 41 42 43 #ifdef PROFILE 44 #include <perfview.h> 45 #endif /* PROFILE */ 46 41 47 42 48 extern char szErrorTitle[]; … … 141 147 } 142 148 OS2UnsetExceptionHandler(&exceptFrame); 143 149 150 #ifdef PROFILE 151 // Note: after this point, we might start collecting performance 152 // information about the called functions. 153 PerfView_Initialize(); 154 #endif /* PROFILE */ 155 156 144 157 WinExe->start(); 145 158 -
TabularUnified trunk/src/kernel32/wprocess.cpp ¶
r7010 r7025 1 /* $Id: wprocess.cpp,v 1.13 5 2001-10-11 01:00:12phaller Exp $ */1 /* $Id: wprocess.cpp,v 1.136 2001-10-12 00:49:23 phaller Exp $ */ 2 2 3 3 /* … … 47 47 #define DBG_LOCALLOG DBG_wprocess 48 48 #include "dbglocal.h" 49 50 #ifdef PROFILE 51 #include <perfview.h> 52 #endif /* PROFILE */ 53 49 54 50 55 ODINDEBUGCHANNEL(KERNEL32-WPROCESS)
Note:
See TracChangeset
for help on using the changeset viewer.