Pyperformance and -DDYNAMIC_EXECUTION_PROFILE
I'm interested in some dynamic execution counts (sys.getdxp). I have a Python executable built with that. The recommended way to capture execution profiles is to run the desired program with -i and use that to grab and write the opcode profile.
That would be quite cumbersome when using pyperformance since each benchmark is run as a separate Python process and there are so many benchmarks. Is there some builtin way to save the output of sys.getdxp() after each benchmark is run? If not, is there an approach to that I should consider, perhaps a plug-in capability I missed in a quick skim of the docs?
Thanks,
Skip Montanaro
I'm interested in some dynamic execution counts (sys.getdxp). I have a Python executable built with that. The recommended way to capture execution profiles is to run the desired program with -i and use that to grab and write the opcode profile.
That would be quite cumbersome when using pyperformance since each benchmark is run as a separate Python process and there are so many benchmarks.
I bit the bullet and set PYINTROSPECT=true, then pasted this little snippet of code at each introspection prompt:
import pickle import sys COUNTFILE = "/tmp/dxp-profile.pck" try: counts = pickle.load(open(COUNTFILE, "rb")) except IOError: counts = sys.getdxp() else: new_counts = sys.getdxp() counts = [sum(pair) for pair in zip(counts, new_counts)] pickle.dump(counts, open(COUNTFILE, "wb")) raise SystemExit
then went about my business, typing Shift-Ctrl-v whenever I noticed the REPL prompt. Since I shouldn't have to do this on a regular basis, that's good enough for now. Still seems like it might be nice to be able to execute a snippet of code automagically after the end of each benchmark, perhaps by taking advantage of Python's -i flag.
Skip
participants (1)
-
Skip Montanaro