| OLD | NEW |
| (Empty) |
| 1 # Copyright (c) 2001-2007 Twisted Matrix Laboratories. | |
| 2 # See LICENSE for details. | |
| 3 | |
| 4 """ | |
| 5 DEPRECATED since Twisted 8.0. | |
| 6 | |
| 7 Utility functions for reporting bytecode frequencies to Skip Montanaro's | |
| 8 stat collector. | |
| 9 | |
| 10 This module requires a version of Python build with DYNAMIC_EXCUTION_PROFILE, | |
| 11 and optionally DXPAIRS, defined to be useful. | |
| 12 """ | |
| 13 | |
| 14 import sys, types, xmlrpclib, warnings | |
| 15 | |
| 16 | |
| 17 warnings.warn("twisted.python.dxprofile is deprecated since Twisted 8.0.", | |
| 18 category=DeprecationWarning) | |
| 19 | |
| 20 | |
| 21 def rle(iterable): | |
| 22 """ | |
| 23 Run length encode a list. | |
| 24 """ | |
| 25 iterable = iter(iterable) | |
| 26 runlen = 1 | |
| 27 result = [] | |
| 28 try: | |
| 29 previous = iterable.next() | |
| 30 except StopIteration: | |
| 31 return [] | |
| 32 for element in iterable: | |
| 33 if element == previous: | |
| 34 runlen = runlen + 1 | |
| 35 continue | |
| 36 else: | |
| 37 if isinstance(previous, (types.ListType, types.TupleType)): | |
| 38 previous = rle(previous) | |
| 39 result.append([previous, runlen]) | |
| 40 previous = element | |
| 41 runlen = 1 | |
| 42 if isinstance(previous, (types.ListType, types.TupleType)): | |
| 43 previous = rle(previous) | |
| 44 result.append([previous, runlen]) | |
| 45 return result | |
| 46 | |
| 47 | |
| 48 | |
| 49 def report(email, appname): | |
| 50 """ | |
| 51 Send an RLE encoded version of sys.getdxp() off to our Top Men (tm) | |
| 52 for analysis. | |
| 53 """ | |
| 54 if hasattr(sys, 'getdxp') and appname: | |
| 55 dxp = xmlrpclib.ServerProxy("http://manatee.mojam.com:7304") | |
| 56 dxp.add_dx_info(appname, email, sys.version_info[:3], rle(sys.getdxp())) | |
| OLD | NEW |