Memory testing in Python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • csselo@gmail.com

    #1

    Memory testing in Python

    Hi all

    I want to test my python code for memory efficiency in gnu/linux.How
    can I do this?

    thanks.

  • Cameron Laird

    #2
    Re: Memory testing in Python

    In article <1175242912.103 313.99110@n59g2 000hsh.googlegr oups.com>,
    <csselo@gmail.c omwrote:
    >Hi all
    >
    >I want to test my python code for memory efficiency in gnu/linux.How
    >can I do this?

    Comment

    • mkPyVS

      #3
      Re: Memory testing in Python

      >While I have a great deal of interest in memory management,
      >my general reaction to your question as you've posed it is,
      >"Don't; concentrate for now on good Python style."
      I agree but for monitoring...

      I've had good luck with executing a popen to grab and parse output
      from ps -Af and pass it your own process ID as the search. It adds
      overhead to the cpu exec time but it is much less than 1sec so you
      won't see it.

      Comment

      • Cameron Laird

        #4
        Re: Memory testing in Python

        In article <1175266111.159 492.131320@l77g 2000hsb.googleg roups.com>,
        mkPyVS <mikeminer53@ho tmail.comwrote:
        >>While I have a great deal of interest in memory management,
        >>my general reaction to your question as you've posed it is,
        >>"Don't; concentrate for now on good Python style."
        >
        >I agree but for monitoring...
        >
        >I've had good luck with executing a popen to grab and parse output
        >from ps -Af and pass it your own process ID as the search. It adds
        >overhead to the cpu exec time but it is much less than 1sec so you
        >won't see it.
        >
        Fair enough.

        Did you intend to suggest "ps -F"? While ps remains not-so-well
        standardized, I know of no version where "ps -Af" details *memory*
        usage.

        Parsing can be simplified with such invocations as
        ps -o pid -o rss -o size -o cmd
        (which can itself be rewritten in various ways, depending on the
        flavor of ps involved).

        Comment

        Working...