RE: Python Module for Determining CPU Freq. and Memory?
[efrat] |I'd like to determine at runtime the computer's CPU frequency and | memory. | | (Please note: I'm interested in hardware stuff, like how much | memory the | machine has; not how much free memory is available.) I don't know if there's a cross-platform solution for this. For Windows, you could use WMI. Something like this: code import wmi c = wmi.WMI () for i in c.Win32_ComputerSystem (): print i.TotalPhysicalMemory for i in c.Win32_Processor (): print i.DeviceID, i.MaxClockSpeed, MHz /code You can get the wmi module from: http://timgolden.me.uk/python/wmi.html TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Module for Determining CPU Freq. and Memory?
efrat wrote: Hello, I'd like to determine at runtime the computer's CPU frequency and memory. Is there a module for these types of queries? platform.platform returns the computer's CPU name and type, but not its frequency; nor does it report how much memory the computer has. In the python help(), I searched for moudles cpu, but non were found. (Please note: I'm interested in hardware stuff, like how much memory the machine has; not how much free memory is available.) Many Thanks, Efrat For looking at memory on windows you might be able to make improvements to this class I wrote. I was going to add memget() methods for getting individual items, but it wasn't as useful as I was hoping it would be in checking my python memory use. For that I need info on individual tasks, but this might be better for your use. Cheers, Ron from ctypes import * from ctypes.wintypes import DWORD SIZE_T = c_ulong class MemStat(Structure): _fields_ = [ (dwLength, DWORD), (dwMemoryLength, DWORD), (dwTotalPhys, SIZE_T), (dwAvailPhys, SIZE_T), (dwTotalPageFile, SIZE_T), (dwAvailPageFile, SIZE_T), (dwTotalVirtual, SIZE_T), (dwAvailVirtualPhys, SIZE_T) ] def update(self): windll.kernel32.GlobalMemoryStatus(byref(self)) def show(self): self.update() result = [] for field_name, field_type in self._fields_: result.append(%s, %s\n \ % (field_name, getattr(self, field_name))) return ''.join(result) memstat = MemStat() if __name__ == '__main__': print memstat.show() -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Module for Determining CPU Freq. and Memory?
Tim Golden wrote: [efrat] |I'd like to determine at runtime the computer's CPU frequency and | memory. | | (Please note: I'm interested in hardware stuff, like how much | memory the | machine has; not how much free memory is available.) I don't know if there's a cross-platform solution for this. For Windows, you could use WMI. Something like this: -cut- For linux (and also for other *nix?) something like this os.system(cat /proc/cpuinfo | grep cpu) cpu family : 6 cpu MHz : 1922.308 or: open(/proc/cpuinfo).readlines() ['processor\t: 0\n', 'vendor_id\t: AuthenticAMD\n' Michele -- http://mail.python.org/mailman/listinfo/python-list