diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..e2701be --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +include LICENSE +include README.rst +recursive-include djangobench/benchmarks * diff --git a/djangobench/benchmarks/l10n_render/benchmark.py b/djangobench/benchmarks/l10n_render/benchmark.py index 535f8ff..f559b56 100644 --- a/djangobench/benchmarks/l10n_render/benchmark.py +++ b/djangobench/benchmarks/l10n_render/benchmark.py @@ -1,4 +1,5 @@ import os +import sys from django.core.handlers.wsgi import WSGIRequest from django.shortcuts import render_to_response @@ -17,7 +18,9 @@ def make_request(): 'SERVER_NAME': 'testserver', 'SERVER_PORT': 80, 'SERVER_PROTOCOL': 'HTTP/1.1', + "wsgi.input": sys.stdin } + return WSGIRequest(environ) diff --git a/djangobench/utils.py b/djangobench/utils.py index 3fa1a27..301ebe3 100644 --- a/djangobench/utils.py +++ b/djangobench/utils.py @@ -1,7 +1,11 @@ import argparse import inspect import os -import time + +# timeit uses either time.time() or time.clock() depending on which is more +# accurate on the current platform: +from timeit import default_timer as time_f + try: import cProfile as profile except ImportError: @@ -57,7 +61,7 @@ def run_benchmark(benchmark, syncdb=True, setup=None, trials=None, handle_argv=T setup() for x in xrange(trials): - start = time.clock() + start = time_f() profile_file = os.environ.get('DJANGOBENCH_PROFILE_FILE', None) if profile_file is not None: loc = locals().copy() @@ -68,7 +72,7 @@ def run_benchmark(benchmark, syncdb=True, setup=None, trials=None, handle_argv=T if benchmark_result is not None: print benchmark_result else: - print time.clock() - start + print time_f() - start def run_comparison_benchmark(benchmark_a, benchmark_b, syncdb=True, setup=None, trials=None, handle_argv=True, meta={}): """ @@ -101,13 +105,13 @@ def run_comparison_benchmark(benchmark_a, benchmark_b, syncdb=True, setup=None, setup() for x in xrange(trials): - start_a = time.clock() + start_a = time_f() result_a = benchmark_a() - result_a = result_a or time.clock() - start_a + result_a = result_a or time_f() - start_a - start_b = time.clock() + start_b = time_f() result_b = benchmark_b() - result_b = result_b or time.clock() - start_b + result_b = result_b or time_f() - start_b print result_a - result_b diff --git a/setup.py b/setup.py index 86e5e84..da9f2c5 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,8 @@ def read(fname): author = 'Jacob Kaplan-Moss', author_email = 'jacob@jacobian.org', packages = find_packages(), + include_package_data = True, + zip_safe=False, classifiers = [ 'Development Status :: 4 - Beta', 'Environment :: Console', @@ -30,4 +32,4 @@ def read(fname): entry_points = { 'console_scripts': ['djangobench = djangobench.main:main'] } -) \ No newline at end of file +)