Skip to content

Commit

Permalink
Merge remote-tracking branch 'acdha/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobian committed Apr 11, 2011
2 parents 60fea38 + fdd3e02 commit 9e04e3a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include LICENSE
include README.rst
recursive-include djangobench/benchmarks *
3 changes: 3 additions & 0 deletions djangobench/benchmarks/l10n_render/benchmark.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys

from django.core.handlers.wsgi import WSGIRequest
from django.shortcuts import render_to_response
Expand All @@ -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)


Expand Down
18 changes: 11 additions & 7 deletions djangobench/utils.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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()
Expand All @@ -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={}):
"""
Expand Down Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -30,4 +32,4 @@ def read(fname):
entry_points = {
'console_scripts': ['djangobench = djangobench.main:main']
}
)
)

0 comments on commit 9e04e3a

Please sign in to comment.