You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.5 KiB
46 lines
1.5 KiB
#!/usr/bin/env python
|
|
# encoding: utf-8
|
|
|
|
# VARS = --none--
|
|
profiler_file_string = """
|
|
#!/usr/bin/env python
|
|
# encoding: utf-8
|
|
|
|
import cProfile, pstats, StringIO
|
|
|
|
def profile():
|
|
#------------------------------------------------------------------------------
|
|
# Setup a profile
|
|
#------------------------------------------------------------------------------
|
|
pr = cProfile.Profile()
|
|
#------------------------------------------------------------------------------
|
|
# Enter setup code below
|
|
#------------------------------------------------------------------------------
|
|
# Optional: include setup code here
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
# Start profiler
|
|
#------------------------------------------------------------------------------
|
|
pr.enable()
|
|
|
|
#------------------------------------------------------------------------------
|
|
# BEGIN profiled code block
|
|
#------------------------------------------------------------------------------
|
|
# include profiled code here
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
# END profiled code block
|
|
#------------------------------------------------------------------------------
|
|
pr.disable()
|
|
s = StringIO.StringIO()
|
|
sortby = 'cumulative'
|
|
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
|
|
ps.strip_dirs().sort_stats("time").print_stats()
|
|
print(s.getvalue())
|
|
|
|
if __name__ == '__main__':
|
|
profile()
|
|
"""
|