def report(email, appname): """ Send an RLE encoded version of sys.getdxp() off to our Top Men (tm) for analysis. """ if hasattr(sys, 'getdxp') and appname: dxp = xmlrpclib.ServerProxy("http://manatee.mojam.com:7304") dxp.add_dx_info(appname, email, sys.version_info[:3], rle(sys.getdxp()))
def merge_profile(): """Reads sys.getdxp() and merges it into this module's cached copy. We need this because sys.getdxp() 0s itself every time it's called.""" with _profile_lock: new_profile = sys.getdxp() if has_pairs(new_profile): for first_inst in range(len(_cumulative_profile)): for second_inst in range(len(_cumulative_profile[first_inst])): _cumulative_profile[first_inst][second_inst] += new_profile[first_inst][second_inst] else: for inst in range(len(_cumulative_profile)): _cumulative_profile[inst] += new_profile[inst]
def merge_profile(): """Reads sys.getdxp() and merges it into this module's cached copy. We need this because sys.getdxp() 0s itself every time it's called.""" with _profile_lock: new_profile = sys.getdxp() if has_pairs(new_profile): for first_inst in range(len(_cumulative_profile)): for second_inst in range(len(_cumulative_profile[first_inst])): _cumulative_profile[first_inst][second_inst] += ( new_profile[first_inst][second_inst]) else: for inst in range(len(_cumulative_profile)): _cumulative_profile[inst] += new_profile[inst]
def ResetProfile(): """Forgets any execution profile that has been gathered so far.""" with _profile_lock: sys.getdxp() # Resets the internal profile _cumulative_profile = sys.getdxp() # 0s out our copy.
""" import copy import opcode import operator import sys import threading import warnings if not hasattr(sys, "getdxp"): raise RuntimeError("Can't import analyze_dxp: Python built without" " -DDYNAMIC_EXECUTION_PROFILE.") _profile_lock = threading.RLock() _cumulative_profile = sys.getdxp() # If Python was built with -DDXPAIRS, sys.getdxp() returns a list of # lists of ints. Otherwise it returns just a list of ints. def HasPairs(profile): """Returns True if the Python that produced the argument profile was built with -DDXPAIRS.""" return len(profile) > 0 and isinstance(profile[0], list) def ResetProfile(): """Forgets any execution profile that has been gathered so far.""" with _profile_lock: sys.getdxp() # Resets the internal profile _cumulative_profile = sys.getdxp() # 0s out our copy.
def reset_profile(): """Forgets any execution profile that has been gathered so far.""" with _profile_lock: sys.getdxp() # Resets the internal profile global _cumulative_profile _cumulative_profile = sys.getdxp() # 0s out our copy.
> s = render_common_pairs() > open('/tmp/some_file', 'w').write(s) """ import copy import opcode import operator import sys import threading if not hasattr(sys, "getdxp"): raise RuntimeError("Can't import analyze_dxp: Python built without" " -DDYNAMIC_EXECUTION_PROFILE.") _profile_lock = threading.RLock() _cumulative_profile = sys.getdxp() # If Python was built with -DDXPAIRS, sys.getdxp() returns a list of # lists of ints. Otherwise it returns just a list of ints. def has_pairs(profile): """Returns True if the Python that produced the argument profile was built with -DDXPAIRS.""" return len(profile) > 0 and isinstance(profile[0], list) def reset_profile(): """Forgets any execution profile that has been gathered so far.""" with _profile_lock: sys.getdxp() # Resets the internal profile