Changeset 7094
- Timestamp:
- May 27, 2009, 8:51:30 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/numpy/anuga/utilities/log.py
r7093 r7094 244 244 log(level, msg) 245 245 else: 246 # fromhttp://code.activestate.com/recipes/511491/246 # Windows code from: http://code.activestate.com/recipes/511491/ 247 247 try: 248 248 import ctypes 249 249 import _winreg 250 250 except: 251 log( CRITICAL, 'Windows resource usage not available')251 log(level, 'Windows resource usage not available') 252 252 return 253 253 254 254 kernel32 = ctypes.windll.kernel32 255 255 c_ulong = ctypes.c_ulong 256 class MEMORYSTATUS(ctypes.Structure): 256 c_ulonglong = ctypes.c_ulonglong 257 class MEMORYSTATUSEX(ctypes.Structure): 257 258 _fields_ = [('dwLength', c_ulong), 258 259 ('dwMemoryLoad', c_ulong), 259 ('dwTotalPhys', c_ulong), 260 ('dwAvailPhys', c_ulong), 261 ('dwTotalPageFile', c_ulong), 262 ('dwAvailPageFile', c_ulong), 263 ('dwTotalVirtual', c_ulong), 264 ('dwAvailVirtual', c_ulong) 260 ('ullTotalPhys', c_ulonglong), 261 ('ullAvailPhys', c_ulonglong), 262 ('ullTotalPageFile', c_ulonglong), 263 ('ullAvailPageFile', c_ulonglong), 264 ('ullTotalVirtual', c_ulonglong), 265 ('ullAvailVirtual', c_ulonglong), 266 ('ullAvailExtendedVirtual', c_ulonglong) 265 267 ] 266 267 memoryStatus = MEMORYSTATUS()268 memoryStatus.dwLength = ctypes.sizeof(MEMORYSTATUS )269 kernel32.GlobalMemoryStatus (ctypes.byref(memoryStatus))268 269 memoryStatusEx = MEMORYSTATUSEX() 270 memoryStatus.dwLength = ctypes.sizeof(MEMORYSTATUSEX) 271 kernel32.GlobalMemoryStatusEx(ctypes.byref(memoryStatusEx)) 270 272 271 273 msg = ('Resource usage: total memory=%.1fMB free memory=%.1fMB' 272 % (memoryStatus .dwTotalPhys/_scale['MB'],273 memoryStatus .dwAvailPhys/_scale['MB']))274 % (memoryStatusEx.ullTotalPhys/_scale['MB'], 275 memoryStatusEx.ullAvailPhys/_scale['MB'])) 274 276 log(level, msg) 275 277
Note: See TracChangeset
for help on using the changeset viewer.