Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenperfpage.c
Go to the documentation of this file.
00001 /* 00002 * ReactOS Task Manager 00003 * 00004 * perfpage.c 00005 * 00006 * Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org> 00007 * 00008 * This program is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License along 00019 * with this program; if not, write to the Free Software Foundation, Inc., 00020 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00021 */ 00022 00023 #include <precomp.h> 00024 00025 TGraphCtrl PerformancePageCpuUsageHistoryGraph; 00026 TGraphCtrl PerformancePageMemUsageHistoryGraph; 00027 00028 HWND hPerformancePage; /* Performance Property Page */ 00029 HWND hPerformancePageCpuUsageGraph; /* CPU Usage Graph */ 00030 HWND hPerformancePageMemUsageGraph; /* MEM Usage Graph */ 00031 HWND hPerformancePageCpuUsageHistoryGraph; /* CPU Usage History Graph */ 00032 HWND hPerformancePageMemUsageHistoryGraph; /* Memory Usage History Graph */ 00033 HWND hPerformancePageTotalsFrame; /* Totals Frame */ 00034 HWND hPerformancePageCommitChargeFrame; /* Commit Charge Frame */ 00035 HWND hPerformancePageKernelMemoryFrame; /* Kernel Memory Frame */ 00036 HWND hPerformancePagePhysicalMemoryFrame; /* Physical Memory Frame */ 00037 HWND hPerformancePageCpuUsageFrame; 00038 HWND hPerformancePageMemUsageFrame; 00039 HWND hPerformancePageCpuUsageHistoryFrame; 00040 HWND hPerformancePageMemUsageHistoryFrame; 00041 HWND hPerformancePageCommitChargeTotalEdit; /* Commit Charge Total Edit Control */ 00042 HWND hPerformancePageCommitChargeLimitEdit; /* Commit Charge Limit Edit Control */ 00043 HWND hPerformancePageCommitChargePeakEdit; /* Commit Charge Peak Edit Control */ 00044 HWND hPerformancePageKernelMemoryTotalEdit; /* Kernel Memory Total Edit Control */ 00045 HWND hPerformancePageKernelMemoryPagedEdit; /* Kernel Memory Paged Edit Control */ 00046 HWND hPerformancePageKernelMemoryNonPagedEdit; /* Kernel Memory NonPaged Edit Control */ 00047 HWND hPerformancePagePhysicalMemoryTotalEdit; /* Physical Memory Total Edit Control */ 00048 HWND hPerformancePagePhysicalMemoryAvailableEdit; /* Physical Memory Available Edit Control */ 00049 HWND hPerformancePagePhysicalMemorySystemCacheEdit; /* Physical Memory System Cache Edit Control */ 00050 HWND hPerformancePageTotalsHandleCountEdit; /* Total Handles Edit Control */ 00051 HWND hPerformancePageTotalsProcessCountEdit; /* Total Processes Edit Control */ 00052 HWND hPerformancePageTotalsThreadCountEdit; /* Total Threads Edit Control */ 00053 00054 #ifdef RUN_PERF_PAGE 00055 static HANDLE hPerformanceThread = NULL; 00056 static DWORD dwPerformanceThread; 00057 #endif 00058 00059 static int nPerformancePageWidth; 00060 static int nPerformancePageHeight; 00061 static int lastX, lastY; 00062 DWORD WINAPI PerformancePageRefreshThread(void *lpParameter); 00063 00064 void AdjustFrameSize(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference, int pos) 00065 { 00066 RECT rc; 00067 int cx, cy, sx, sy; 00068 00069 GetClientRect(hCntrl, &rc); 00070 MapWindowPoints(hCntrl, hDlg, (LPPOINT)(PRECT)(&rc), (sizeof(RECT)/sizeof(POINT))); 00071 if (pos) { 00072 cx = rc.left; 00073 cy = rc.top; 00074 sx = rc.right - rc.left; 00075 switch (pos) { 00076 case 1: 00077 break; 00078 case 2: 00079 cy += nYDifference / 2; 00080 break; 00081 case 3: 00082 sx += nXDifference; 00083 break; 00084 case 4: 00085 cy += nYDifference / 2; 00086 sx += nXDifference; 00087 break; 00088 } 00089 sy = rc.bottom - rc.top + nYDifference / 2; 00090 SetWindowPos(hCntrl, NULL, cx, cy, sx, sy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER); 00091 } else { 00092 cx = rc.left + nXDifference; 00093 cy = rc.top + nYDifference; 00094 sx = sy = 0; 00095 SetWindowPos(hCntrl, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); 00096 } 00097 InvalidateRect(hCntrl, NULL, TRUE); 00098 } 00099 00100 static void AdjustControlPostion(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference) 00101 { 00102 AdjustFrameSize(hCntrl, hDlg, nXDifference, nYDifference, 0); 00103 } 00104 00105 static void AdjustCntrlPos(int ctrl_id, HWND hDlg, int nXDifference, int nYDifference) 00106 { 00107 AdjustFrameSize(GetDlgItem(hDlg, ctrl_id), hDlg, nXDifference, nYDifference, 0); 00108 } 00109 00110 INT_PTR CALLBACK 00111 PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) 00112 { 00113 RECT rc; 00114 int nXDifference; 00115 int nYDifference; 00116 /* HDC hdc; */ 00117 /* PAINTSTRUCT ps; */ 00118 00119 switch (message) { 00120 case WM_DESTROY: 00121 GraphCtrl_Dispose(&PerformancePageCpuUsageHistoryGraph); 00122 GraphCtrl_Dispose(&PerformancePageMemUsageHistoryGraph); 00123 #ifdef RUN_PERF_PAGE 00124 EndLocalThread(&hPerformanceThread, dwPerformanceThread); 00125 #endif 00126 break; 00127 00128 case WM_INITDIALOG: 00129 00130 /* Save the width and height */ 00131 GetClientRect(hDlg, &rc); 00132 nPerformancePageWidth = rc.right; 00133 nPerformancePageHeight = rc.bottom; 00134 00135 /* Update window position */ 00136 SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); 00137 00138 /* 00139 * Get handles to all the controls 00140 */ 00141 hPerformancePageTotalsFrame = GetDlgItem(hDlg, IDC_TOTALS_FRAME); 00142 hPerformancePageCommitChargeFrame = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_FRAME); 00143 hPerformancePageKernelMemoryFrame = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_FRAME); 00144 hPerformancePagePhysicalMemoryFrame = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_FRAME); 00145 00146 hPerformancePageCpuUsageFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_FRAME); 00147 hPerformancePageMemUsageFrame = GetDlgItem(hDlg, IDC_MEM_USAGE_FRAME); 00148 hPerformancePageCpuUsageHistoryFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_FRAME); 00149 hPerformancePageMemUsageHistoryFrame = GetDlgItem(hDlg, IDC_MEMORY_USAGE_HISTORY_FRAME); 00150 00151 hPerformancePageCommitChargeTotalEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_TOTAL); 00152 hPerformancePageCommitChargeLimitEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_LIMIT); 00153 hPerformancePageCommitChargePeakEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_PEAK); 00154 hPerformancePageKernelMemoryTotalEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_TOTAL); 00155 hPerformancePageKernelMemoryPagedEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_PAGED); 00156 hPerformancePageKernelMemoryNonPagedEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_NONPAGED); 00157 hPerformancePagePhysicalMemoryTotalEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_TOTAL); 00158 hPerformancePagePhysicalMemoryAvailableEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_AVAILABLE); 00159 hPerformancePagePhysicalMemorySystemCacheEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_SYSTEM_CACHE); 00160 hPerformancePageTotalsHandleCountEdit = GetDlgItem(hDlg, IDC_TOTALS_HANDLE_COUNT); 00161 hPerformancePageTotalsProcessCountEdit = GetDlgItem(hDlg, IDC_TOTALS_PROCESS_COUNT); 00162 hPerformancePageTotalsThreadCountEdit = GetDlgItem(hDlg, IDC_TOTALS_THREAD_COUNT); 00163 00164 hPerformancePageCpuUsageGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_GRAPH); 00165 hPerformancePageMemUsageGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_GRAPH); 00166 hPerformancePageMemUsageHistoryGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_HISTORY_GRAPH); 00167 hPerformancePageCpuUsageHistoryGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_GRAPH); 00168 00169 GetClientRect(hPerformancePageCpuUsageHistoryGraph, &rc); 00170 /* create the control */ 00171 /* PerformancePageCpuUsageHistoryGraph.Create(0, rc, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH); */ 00172 GraphCtrl_Create(&PerformancePageCpuUsageHistoryGraph, hPerformancePageCpuUsageHistoryGraph, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH); 00173 /* customize the control */ 00174 GraphCtrl_SetRange(&PerformancePageCpuUsageHistoryGraph, 0.0, 100.0, 10); 00175 /* PerformancePageCpuUsageHistoryGraph.SetYUnits("Current") ; */ 00176 /* PerformancePageCpuUsageHistoryGraph.SetXUnits("Samples (Windows Timer: 100 msec)") ; */ 00177 /* PerformancePageCpuUsageHistoryGraph.SetBackgroundColor(RGB(0, 0, 64)) ; */ 00178 /* PerformancePageCpuUsageHistoryGraph.SetGridColor(RGB(192, 192, 255)) ; */ 00179 /* PerformancePageCpuUsageHistoryGraph.SetPlotColor(RGB(255, 255, 255)) ; */ 00180 GraphCtrl_SetBackgroundColor(&PerformancePageCpuUsageHistoryGraph, RGB(0, 0, 0)) ; 00181 GraphCtrl_SetGridColor(&PerformancePageCpuUsageHistoryGraph, RGB(0, 128, 64)); 00182 00183 GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 0, RGB(0, 255, 0)) ; 00184 GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 1, RGB(255, 0, 0)) ; 00185 00186 00187 GetClientRect(hPerformancePageMemUsageHistoryGraph, &rc); 00188 GraphCtrl_Create(&PerformancePageMemUsageHistoryGraph, hPerformancePageMemUsageHistoryGraph, hDlg, IDC_MEM_USAGE_HISTORY_GRAPH); 00189 GraphCtrl_SetRange(&PerformancePageMemUsageHistoryGraph, 0.0, 100.0, 10) ; 00190 GraphCtrl_SetBackgroundColor(&PerformancePageMemUsageHistoryGraph, RGB(0, 0, 0)) ; 00191 GraphCtrl_SetGridColor(&PerformancePageMemUsageHistoryGraph, RGB(0, 128, 64)) ; 00192 GraphCtrl_SetPlotColor(&PerformancePageMemUsageHistoryGraph, 0, RGB(255, 255, 0)) ; 00193 /* Start our refresh thread */ 00194 #ifdef RUN_PERF_PAGE 00195 hPerformanceThread = CreateThread(NULL, 0, PerformancePageRefreshThread, NULL, 0, &dwPerformanceThread); 00196 #endif 00197 00198 /* 00199 * Subclass graph buttons 00200 */ 00201 OldGraphWndProc = (WNDPROC)(LONG_PTR) SetWindowLongPtrW(hPerformancePageCpuUsageGraph, GWL_WNDPROC, (LONG_PTR)Graph_WndProc); 00202 SetWindowLongPtrW(hPerformancePageMemUsageGraph, GWL_WNDPROC, (LONG_PTR)Graph_WndProc); 00203 OldGraphCtrlWndProc = (WNDPROC)(LONG_PTR) SetWindowLongPtrW(hPerformancePageMemUsageHistoryGraph, GWL_WNDPROC, (LONG_PTR)GraphCtrl_WndProc); 00204 SetWindowLongPtrW(hPerformancePageCpuUsageHistoryGraph, GWL_WNDPROC, (LONG_PTR)GraphCtrl_WndProc); 00205 return TRUE; 00206 00207 case WM_COMMAND: 00208 break; 00209 #if 0 00210 case WM_NCPAINT: 00211 hdc = GetDC(hDlg); 00212 GetClientRect(hDlg, &rc); 00213 Draw3dRect(hdc, rc.left, rc.top, rc.right, rc.top + 2, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT)); 00214 ReleaseDC(hDlg, hdc); 00215 break; 00216 00217 case WM_PAINT: 00218 hdc = BeginPaint(hDlg, &ps); 00219 GetClientRect(hDlg, &rc); 00220 Draw3dRect(hdc, rc.left, rc.top, rc.right, rc.top + 2, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT)); 00221 EndPaint(hDlg, &ps); 00222 break; 00223 #endif 00224 case WM_SIZE: 00225 do { 00226 int cx, cy; 00227 00228 if (wParam == SIZE_MINIMIZED) 00229 return 0; 00230 00231 cx = LOWORD(lParam); 00232 cy = HIWORD(lParam); 00233 nXDifference = cx - nPerformancePageWidth; 00234 nYDifference = cy - nPerformancePageHeight; 00235 nPerformancePageWidth = cx; 00236 nPerformancePageHeight = cy; 00237 } while (0); 00238 00239 /* Reposition the performance page's controls */ 00240 AdjustFrameSize(hPerformancePageTotalsFrame, hDlg, 0, nYDifference, 0); 00241 AdjustFrameSize(hPerformancePageCommitChargeFrame, hDlg, 0, nYDifference, 0); 00242 AdjustFrameSize(hPerformancePageKernelMemoryFrame, hDlg, 0, nYDifference, 0); 00243 AdjustFrameSize(hPerformancePagePhysicalMemoryFrame, hDlg, 0, nYDifference, 0); 00244 AdjustCntrlPos(IDS_COMMIT_CHARGE_TOTAL, hDlg, 0, nYDifference); 00245 AdjustCntrlPos(IDS_COMMIT_CHARGE_LIMIT, hDlg, 0, nYDifference); 00246 AdjustCntrlPos(IDS_COMMIT_CHARGE_PEAK, hDlg, 0, nYDifference); 00247 AdjustCntrlPos(IDS_KERNEL_MEMORY_TOTAL, hDlg, 0, nYDifference); 00248 AdjustCntrlPos(IDS_KERNEL_MEMORY_PAGED, hDlg, 0, nYDifference); 00249 AdjustCntrlPos(IDS_KERNEL_MEMORY_NONPAGED, hDlg, 0, nYDifference); 00250 AdjustCntrlPos(IDS_PHYSICAL_MEMORY_TOTAL, hDlg, 0, nYDifference); 00251 AdjustCntrlPos(IDS_PHYSICAL_MEMORY_AVAILABLE, hDlg, 0, nYDifference); 00252 AdjustCntrlPos(IDS_PHYSICAL_MEMORY_SYSTEM_CACHE, hDlg, 0, nYDifference); 00253 AdjustCntrlPos(IDS_TOTALS_HANDLE_COUNT, hDlg, 0, nYDifference); 00254 AdjustCntrlPos(IDS_TOTALS_PROCESS_COUNT, hDlg, 0, nYDifference); 00255 AdjustCntrlPos(IDS_TOTALS_THREAD_COUNT, hDlg, 0, nYDifference); 00256 00257 AdjustControlPostion(hPerformancePageCommitChargeTotalEdit, hDlg, 0, nYDifference); 00258 AdjustControlPostion(hPerformancePageCommitChargeLimitEdit, hDlg, 0, nYDifference); 00259 AdjustControlPostion(hPerformancePageCommitChargePeakEdit, hDlg, 0, nYDifference); 00260 AdjustControlPostion(hPerformancePageKernelMemoryTotalEdit, hDlg, 0, nYDifference); 00261 AdjustControlPostion(hPerformancePageKernelMemoryPagedEdit, hDlg, 0, nYDifference); 00262 AdjustControlPostion(hPerformancePageKernelMemoryNonPagedEdit, hDlg, 0, nYDifference); 00263 AdjustControlPostion(hPerformancePagePhysicalMemoryTotalEdit, hDlg, 0, nYDifference); 00264 AdjustControlPostion(hPerformancePagePhysicalMemoryAvailableEdit, hDlg, 0, nYDifference); 00265 AdjustControlPostion(hPerformancePagePhysicalMemorySystemCacheEdit, hDlg, 0, nYDifference); 00266 AdjustControlPostion(hPerformancePageTotalsHandleCountEdit, hDlg, 0, nYDifference); 00267 AdjustControlPostion(hPerformancePageTotalsProcessCountEdit, hDlg, 0, nYDifference); 00268 AdjustControlPostion(hPerformancePageTotalsThreadCountEdit, hDlg, 0, nYDifference); 00269 00270 nXDifference += lastX; 00271 nYDifference += lastY; 00272 lastX = lastY = 0; 00273 if (nXDifference % 2) { 00274 if (nXDifference > 0) { 00275 nXDifference--; 00276 lastX++; 00277 } else { 00278 nXDifference++; 00279 lastX--; 00280 } 00281 } 00282 if (nYDifference % 2) { 00283 if (nYDifference > 0) { 00284 nYDifference--; 00285 lastY++; 00286 } else { 00287 nYDifference++; 00288 lastY--; 00289 } 00290 } 00291 AdjustFrameSize(hPerformancePageCpuUsageFrame, hDlg, nXDifference, nYDifference, 1); 00292 AdjustFrameSize(hPerformancePageMemUsageFrame, hDlg, nXDifference, nYDifference, 2); 00293 AdjustFrameSize(hPerformancePageCpuUsageHistoryFrame, hDlg, nXDifference, nYDifference, 3); 00294 AdjustFrameSize(hPerformancePageMemUsageHistoryFrame, hDlg, nXDifference, nYDifference, 4); 00295 AdjustFrameSize(hPerformancePageCpuUsageGraph, hDlg, nXDifference, nYDifference, 1); 00296 AdjustFrameSize(hPerformancePageMemUsageGraph, hDlg, nXDifference, nYDifference, 2); 00297 AdjustFrameSize(hPerformancePageCpuUsageHistoryGraph, hDlg, nXDifference, nYDifference, 3); 00298 AdjustFrameSize(hPerformancePageMemUsageHistoryGraph, hDlg, nXDifference, nYDifference, 4); 00299 break; 00300 } 00301 return 0; 00302 } 00303 00304 void RefreshPerformancePage(void) 00305 { 00306 #ifdef RUN_PERF_PAGE 00307 /* Signal the event so that our refresh thread */ 00308 /* will wake up and refresh the performance page */ 00309 PostThreadMessage(dwPerformanceThread, WM_TIMER, 0, 0); 00310 #endif 00311 } 00312 00313 DWORD WINAPI PerformancePageRefreshThread(void *lpParameter) 00314 { 00315 ULONG CommitChargeTotal; 00316 ULONG CommitChargeLimit; 00317 ULONG CommitChargePeak; 00318 00319 ULONG CpuUsage; 00320 ULONG CpuKernelUsage; 00321 00322 ULONG KernelMemoryTotal; 00323 ULONG KernelMemoryPaged; 00324 ULONG KernelMemoryNonPaged; 00325 00326 ULONG PhysicalMemoryTotal; 00327 ULONG PhysicalMemoryAvailable; 00328 ULONG PhysicalMemorySystemCache; 00329 00330 ULONG TotalHandles; 00331 ULONG TotalThreads; 00332 ULONG TotalProcesses; 00333 00334 WCHAR Text[260]; 00335 WCHAR szMemUsage[256]; 00336 00337 MSG msg; 00338 00339 LoadStringW(hInst, IDS_STATUS_MEMUSAGE, szMemUsage, 256); 00340 00341 while (1) 00342 { 00343 int nBarsUsed1; 00344 int nBarsUsed2; 00345 00346 /* Wait for an the event or application close */ 00347 if (GetMessage(&msg, NULL, 0, 0) <= 0) 00348 return 0; 00349 00350 if (msg.message == WM_TIMER) 00351 { 00352 /* 00353 * Update the commit charge info 00354 */ 00355 CommitChargeTotal = PerfDataGetCommitChargeTotalK(); 00356 CommitChargeLimit = PerfDataGetCommitChargeLimitK(); 00357 CommitChargePeak = PerfDataGetCommitChargePeakK(); 00358 _ultow(CommitChargeTotal, Text, 10); 00359 SetWindowTextW(hPerformancePageCommitChargeTotalEdit, Text); 00360 _ultow(CommitChargeLimit, Text, 10); 00361 SetWindowTextW(hPerformancePageCommitChargeLimitEdit, Text); 00362 _ultow(CommitChargePeak, Text, 10); 00363 SetWindowTextW(hPerformancePageCommitChargePeakEdit, Text); 00364 wsprintfW(Text, szMemUsage, CommitChargeTotal, CommitChargeLimit); 00365 SendMessageW(hStatusWnd, SB_SETTEXT, 2, (LPARAM)Text); 00366 00367 /* 00368 * Update the kernel memory info 00369 */ 00370 KernelMemoryTotal = PerfDataGetKernelMemoryTotalK(); 00371 KernelMemoryPaged = PerfDataGetKernelMemoryPagedK(); 00372 KernelMemoryNonPaged = PerfDataGetKernelMemoryNonPagedK(); 00373 _ultow(KernelMemoryTotal, Text, 10); 00374 SetWindowTextW(hPerformancePageKernelMemoryTotalEdit, Text); 00375 _ultow(KernelMemoryPaged, Text, 10); 00376 SetWindowTextW(hPerformancePageKernelMemoryPagedEdit, Text); 00377 _ultow(KernelMemoryNonPaged, Text, 10); 00378 SetWindowTextW(hPerformancePageKernelMemoryNonPagedEdit, Text); 00379 00380 /* 00381 * Update the physical memory info 00382 */ 00383 PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK(); 00384 PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK(); 00385 PhysicalMemorySystemCache = PerfDataGetPhysicalMemorySystemCacheK(); 00386 _ultow(PhysicalMemoryTotal, Text, 10); 00387 SetWindowTextW(hPerformancePagePhysicalMemoryTotalEdit, Text); 00388 _ultow(PhysicalMemoryAvailable, Text, 10); 00389 SetWindowTextW(hPerformancePagePhysicalMemoryAvailableEdit, Text); 00390 _ultow(PhysicalMemorySystemCache, Text, 10); 00391 SetWindowTextW(hPerformancePagePhysicalMemorySystemCacheEdit, Text); 00392 00393 /* 00394 * Update the totals info 00395 */ 00396 TotalHandles = PerfDataGetSystemHandleCount(); 00397 TotalThreads = PerfDataGetTotalThreadCount(); 00398 TotalProcesses = PerfDataGetProcessCount(); 00399 _ultow(TotalHandles, Text, 10); 00400 SetWindowTextW(hPerformancePageTotalsHandleCountEdit, Text); 00401 _ultow(TotalThreads, Text, 10); 00402 SetWindowTextW(hPerformancePageTotalsThreadCountEdit, Text); 00403 _ultow(TotalProcesses, Text, 10); 00404 SetWindowTextW(hPerformancePageTotalsProcessCountEdit, Text); 00405 00406 /* 00407 * Redraw the graphs 00408 */ 00409 InvalidateRect(hPerformancePageCpuUsageGraph, NULL, FALSE); 00410 InvalidateRect(hPerformancePageMemUsageGraph, NULL, FALSE); 00411 00412 /* 00413 * Get the CPU usage 00414 */ 00415 CpuUsage = PerfDataGetProcessorUsage(); 00416 if (CpuUsage <= 0 ) CpuUsage = 0; 00417 if (CpuUsage > 100) CpuUsage = 100; 00418 00419 if (TaskManagerSettings.ShowKernelTimes) 00420 { 00421 CpuKernelUsage = PerfDataGetProcessorSystemUsage(); 00422 if (CpuKernelUsage <= 0) CpuKernelUsage = 0; 00423 if (CpuKernelUsage > 100) CpuKernelUsage = 100; 00424 } 00425 else 00426 { 00427 CpuKernelUsage = 0; 00428 } 00429 /* 00430 * Get the memory usage 00431 */ 00432 CommitChargeTotal = PerfDataGetCommitChargeTotalK(); 00433 CommitChargeLimit = PerfDataGetCommitChargeLimitK(); 00434 nBarsUsed1 = CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0; 00435 00436 PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK(); 00437 PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK(); 00438 nBarsUsed2 = PhysicalMemoryTotal ? ((PhysicalMemoryAvailable * 100) / PhysicalMemoryTotal) : 0; 00439 00440 GraphCtrl_AppendPoint(&PerformancePageCpuUsageHistoryGraph, CpuUsage, CpuKernelUsage, 0.0, 0.0); 00441 GraphCtrl_AppendPoint(&PerformancePageMemUsageHistoryGraph, nBarsUsed1, nBarsUsed2, 0.0, 0.0); 00442 /* PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ; */ 00443 InvalidateRect(hPerformancePageMemUsageHistoryGraph, NULL, FALSE); 00444 InvalidateRect(hPerformancePageCpuUsageHistoryGraph, NULL, FALSE); 00445 } 00446 } 00447 return 0; 00448 } 00449 00450 void PerformancePage_OnViewShowKernelTimes(void) 00451 { 00452 HMENU hMenu; 00453 HMENU hViewMenu; 00454 00455 hMenu = GetMenu(hMainWnd); 00456 hViewMenu = GetSubMenu(hMenu, 2); 00457 00458 /* Check or uncheck the show 16-bit tasks menu item */ 00459 if (GetMenuState(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND) & MF_CHECKED) 00460 { 00461 CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_UNCHECKED); 00462 TaskManagerSettings.ShowKernelTimes = FALSE; 00463 } 00464 else 00465 { 00466 CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_CHECKED); 00467 TaskManagerSettings.ShowKernelTimes = TRUE; 00468 } 00469 00470 RefreshPerformancePage(); 00471 } 00472 00473 void PerformancePage_OnViewCPUHistoryOneGraphAll(void) 00474 { 00475 HMENU hMenu; 00476 HMENU hViewMenu; 00477 HMENU hCPUHistoryMenu; 00478 00479 hMenu = GetMenu(hMainWnd); 00480 hViewMenu = GetSubMenu(hMenu, 2); 00481 hCPUHistoryMenu = GetSubMenu(hViewMenu, 3); 00482 00483 TaskManagerSettings.CPUHistory_OneGraphPerCPU = FALSE; 00484 CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHALL, MF_BYCOMMAND); 00485 } 00486 00487 void PerformancePage_OnViewCPUHistoryOneGraphPerCPU(void) 00488 { 00489 HMENU hMenu; 00490 HMENU hViewMenu; 00491 HMENU hCPUHistoryMenu; 00492 00493 hMenu = GetMenu(hMainWnd); 00494 hViewMenu = GetSubMenu(hMenu, 2); 00495 hCPUHistoryMenu = GetSubMenu(hViewMenu, 3); 00496 00497 TaskManagerSettings.CPUHistory_OneGraphPerCPU = TRUE; 00498 CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, MF_BYCOMMAND); 00499 } 00500 Generated on Thu May 24 2012 04:17:46 for ReactOS by
1.7.6.1
|