473,395 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 2074
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Noen | last post by:
Im developing a game where the players will program their equipment with python. Are there any ways to run insecure code? I dont want the clients to mess with the server-code through their own...
6
by: Stefan Behnel | last post by:
Hi! The logging module nicely prepends each line with a formatted date. However, I'm not interested in the actual date but only in the number of milliseconds that passed since the start of the...
10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
137
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 378 open ( +3) / 3298 closed (+34) / 3676 total (+37) Bugs : 886 open (-24) / 5926 closed (+75) / 6812 total (+51) RFE : 224 open...
25
by: John Nagle | last post by:
Some faster Python implementations are under development. JPython has been around for a while, and PyPy and ShedSkin continue to move forward. It's worth thinking about what slows down Python...
8
by: Andrew Savige | last post by:
I'm learning Python by reading David Beazley's "Python Essential Reference" book and writing a few toy programs. To get a feel for hashes and sorting, I set myself this little problem today (not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.