Aktuelle Änderungen Printable View Änderungen Bearbeiten
BusinessRules > C > CLanguage > CASE > ComputerAidedSoftwareEngineering > CLOS > CommonLispObjectSystem > CLR > CommonLanguageRuntime > CLanguage > CPlusPlus > CPlusPlusSprache > CS > ComputerScience > CVS > CallByReferenceOrValue > CallingPythonProfilersFromCommandLineClear TrailSpeed only matters in certain critical bottlenecks.[1]
myscript.py 3 times, accumulating the results
import hotshot, hotshot.stats import os import sys if __name__ == "__main__": if len(sys.argv) == 0: sys.exit() if len(sys.argv) == 3: script = sys.argv[2] repetitions = int(sys.argv[1]) else: script = sys.argv[1] repetitions = 1 # stolen from profile.py # add dirname to python-search-path dirname = os.path.dirname(script) sys.path.insert(0, dirname) hotshot_data = "hotshot_hotcoc_stats" profile = hotshot.Profile(hotshot_data) # execute the script - instead of "%r" - "'%s'" would also work for i in range(repetitions): profile.run("execfile(%r)" % (script,)) profile.close() stats = hotshot.stats.load(hotshot_data) # removing directory-information # time: time spent in function without sub-calls stats = stats.sort_stats('time', 'calls') stats.print_stats()