ivmoptimize.py :  » Development » Psyco » psyco-dist » py-utils » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Development » Psyco 
Psyco » psyco dist » py utils » ivmoptimize.py
"""
python ivmoptimize.py path [ path ... ]

This script optimizes and regenerates the 'ivm' virtual machine
used by Psyco on non-i386 platforms.  You need to compile Psyco
in debugging mode (see below) and use 'psyco.dumpcodebuf()' to
generate one or more dump files called 'psyco.dump'.  Run then
the present script with the path(s) to the 'psyco.dump' file(s).
Finally, you have to recompile Psyco in normal (optimized) mode.

You need SWI Prolog to do that.  http://www.swi-prolog.org/

To compile Psyco in debugging mode, create a file 'preferences.py'
in the same directory as 'setup.py' with the following content:

PROCESSOR = 'ivm'
PSYCO_DEBUG = 1
VERBOSE_LEVEL = 1
CODE_DUMP = 1

and re-run 'python setup.py build -f install'.
"""
import sys, os
import ivmextract

try:
    LOCALDIR = __file__
except NameError:
    LOCALDIR = sys.argv[0]
LOCALDIR = os.path.dirname(LOCALDIR)


def main(paths, maxlength=8, optmode='optimize.pl'):
    outfilenames = [os.path.abspath(ivmextract.main(dir)) for dir in paths]
    os.chdir(os.path.join(LOCALDIR, os.pardir, 'c', 'ivm', 'prolog'))
    g = open("mode_combine.pl", "w")
    g.close()      # empty file
    g = os.popen('pl -f %s -g remotecontrol -t halt' % optmode, 'w')
    for fn in outfilenames:
        print >> g, "loaddumpfile('%s')." % fn
    print >> g, "measure(%d)." % maxlength
    print >> g, "emitmodes(255)."
    g.close()
    g = open("mode_combine.pl", "r")
    if not g.readline():
        print >> sys.stderr, "*** the Prolog program %s failed" % optmode
        sys.exit(1)
    g.close()
    err = os.system('pl -f insns.pl -g main_emit -t halt')
    if err == 0:
        print
        print 'Done.  If you compile Psyco, its ivm virtual machine will now'
        print 'be optimized for the usage patterns found in the dump files.'


if __name__ == '__main__':
    if len(sys.argv) <= 1:
        print >> sys.stderr, __doc__
        sys.exit(2)
    else:
        main(sys.argv[1:])
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.