CVS: python msp430-profile.py,NONE,1.1

Chris Liechti <[email protected]> Sat, 09 Sep 2006 16:50:13 -0700
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.cvs
Message-ID <[email protected]>
Update of /cvsroot/mspgcc/python
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv21303/python

Added Files:
	msp430-profile.py 
Log Message:
the beginnings of a simple statistical profiler

--- NEW FILE: msp430-profile.py ---
# statistical profiler for the MSP430

import mspgcc.jtag
import sys
import os
import time

if __name__ == '__main__':
    mspgcc.jtag.init_backend(mspgcc.jtag.CTYPES_MSPGCC)   #doesn't currently work with 3'rd party libs
    samples = [0] * 2**16

    try:
        jtagobj = mspgcc.jtag.JTAG()
        jtagobj.open()                          #try to open port
        try:
            jtagobj.connect()                   #try to connect to target
            connected = True
            jtagobj.reset(1, 0)
            print "profiling..."
            start_time = time.time()
            while True:
                samples[mspgcc.jtag.MSP430_readMAB()] += 1
        finally:
            stop_time = time.time()
            if sys.exc_info()[:1]:              #if there is an exception pending
                jtagobj.verbose = 0             #do not write any more messages
            if connected:
                jtagobj.reset(1, 1)             #reset and release target
            jtagobj.close()                     #release communication port
    except KeyboardInterrupt:
        total = 0
        for n, count in enumerate(samples):
            if count > 0:
                print "0x%04x\t%d" % (n, count)
            total += count
        print '%d samples in %.2f seconds (%d samples/second)' % (
            total,
            stop_time-start_time,
            total / (stop_time-start_time)
        )


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642