[Python-Dev] Dynamic bytecode analysis

M.-A. Lemburg mal@lemburg.com
Thu, 27 Feb 2003 09:41:11 +0100


Damien Morton wrote:
> So I enhanced the PVM dynamic execution profiler to keep track of quads of
> instructions rather than just pairs. Running it on PyStone, I get the
> following results:

pystone is *not* your typical Python application. If you want
some interesting data, I'd suggest to use applications like
Zope, PySol, Mailman, etc. as basis.

The easiest way to do this is by instrumenting the Python
interpreter used by all these applications and have it write
its data to a pickle every now and then. Here's an example
from the Python 1.5 days:

Opcode frequencies:
------------------------------------------------------------------------
           SET_LINENO(127) :      12036 ================================
            LOAD_FAST(124) :      10366 ===========================
            LOAD_ATTR(105) :       4565 ============
           LOAD_CONST(100) :       4549 ============
              POP_TOP(  1) :       3756 =========
           STORE_FAST(125) :       3580 =========
        CALL_FUNCTION(131) :       2558 ======
        JUMP_IF_FALSE(111) :       2142 =====
          LOAD_GLOBAL(116) :       2056 =====
           COMPARE_OP(106) :       2001 =====
         RETURN_VALUE( 83) :       1593 ====
             FOR_LOOP(114) :       1363 ===
           BINARY_ADD( 23) :       1133 ===
           STORE_NAME( 90) :       1062 ==
        JUMP_ABSOLUTE(113) :        835 ==
        MAKE_FUNCTION(132) :        753 ==
           SETUP_LOOP(120) :        568 =
            POP_BLOCK( 87) :        536 =
         JUMP_FORWARD(110) :        503 =
                   32( 32) :        442 =
         JUMP_IF_TRUE(112) :        438 =
            LOAD_NAME(101) :        425 =
              DUP_TOP(  4) :        421 =
       UNARY_NEGATIVE( 11) :        411 =
         SETUP_EXCEPT(121) :        410 =
                   31( 31) :        409 =

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Software directly from the Source  (#1, Feb 27 2003)
 >>> Python/Zope Products & Consulting ...         http://www.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
Python UK 2003, Oxford:                                     33 days left
EuroPython 2003, Charleroi, Belgium:                       117 days left