471,119 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,119 software developers and data experts.

Python Module for Determining CPU Freq. and Memory?

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
Apr 6 '06 #1
1 2003
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()
Apr 6 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Noen | last post: by
6 posts views Thread by Stefan Behnel | last post: by
10 posts views Thread by Andrew Dalke | last post: by
137 posts views Thread by Philippe C. Martin | last post: by
reply views Thread by Kurt B. Kaiser | last post: by
25 posts views Thread by John Nagle | last post: by
8 posts views Thread by Andrew Savige | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.