RE: Python Module for Determining CPU Freq. and Memory?

Discussion in 'Python' started by Tim Golden, Apr 6, 2006.

  1. Tim Golden

    Tim Golden Guest

    [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
    ________________________________________________________________________
    Tim Golden, Apr 6, 2006
    #1
    1. Advertising

  2. 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
    Michele Petrazzo, Apr 6, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. efrat
    Replies:
    1
    Views:
    714
    Ron Adam
    Apr 6, 2006
  2. noroi
    Replies:
    0
    Views:
    545
    noroi
    Oct 18, 2007
  3. pavunkumar

    How , system cpu and user cpu times calculates

    pavunkumar, Feb 27, 2009, in forum: C Programming
    Replies:
    1
    Views:
    337
  4. Dirk Nachbar

    freq function

    Dirk Nachbar, Aug 22, 2010, in forum: Python
    Replies:
    2
    Views:
    528
    Peter Otten
    Aug 22, 2010
  5. nivparsons

    Sync high freq to 100Hz?

    nivparsons, Feb 16, 2012, in forum: VHDL
    Replies:
    2
    Views:
    721
Loading...

Share This Page