Python Module for Determining CPU Freq. and Memory?

E

efrat

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
 
R

Ron Adam

efrat said:
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()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top