def run(frameworks, number, do_profile):
print("Benchmarking frameworks:", ', '.join(frameworks))
sys.path[0] = '.'
path = os.getcwd()
print(" ms rps tcalls funcs")
for framework in frameworks:
os.chdir(os.path.join(path, framework))
try:
main = __import__('app', None, None, ['main']).main
f = lambda: list(main(environ.copy(), start_response))
time = timeit(f, number=number)
st = Stats(profile.Profile().runctx(
'f()', globals(), locals()))
print("%-11s %6.0f %7.0f %7d %6d" % (framework, 1000 * time,
number / time, st.total_calls, len(st.stats)))
if do_profile:
st = Stats(profile.Profile().runctx(
'timeit(f, number=number)', globals(), locals()))
st.strip_dirs().sort_stats('time').print_stats(10)
del sys.modules['app']
except ImportError:
print("%-15s not installed" % framework)
评论列表
文章目录