Permalink
Browse files

Merge pull request #27 from jaap3/fix_for_master

Fix djangobench for Django 1.10+. Thanks Jaap!
  • Loading branch information...
2 parents b52fccf + a93cfd1 commit d6bb6c6428b4c043a157aadccd2f621dbb68f3d4 @SmileyChris SmileyChris committed on GitHub Aug 15, 2016
View
11 djangobench/benchmarks/default_middleware/urls.py
@@ -1,9 +1,10 @@
try:
- from django.conf.urls import patterns
+ from django.conf.urls import url
except ImportError:
- from django.conf.urls.defaults import patterns
+ from django.conf.urls.defaults import url
+from .views import index
-urlpatterns = patterns('default_middleware',
- (r'^.*$', 'views.index'),
-)
+urlpatterns = [
+ url(r'^.*$', index),
+]
View
8 djangobench/benchmarks/l10n_render/benchmark.py
@@ -19,7 +19,7 @@ def make_request():
'SERVER_PORT': 80,
'SERVER_PROTOCOL': 'HTTP/1.1',
"wsgi.input": sys.stdin
- }
+ }
return WSGIRequest(environ)
@@ -28,9 +28,9 @@ def make_request():
def benchmark():
- render_to_response('list.html',
- {'numbers': range(0, 200)},
- context_instance=RequestContext(req_object))
+ context = RequestContext(req_object)
+ context['numbers'] = range(0, 200)
+ render_to_response('list.html', context)
run_benchmark(
View
21 djangobench/benchmarks/l10n_render/settings.py
@@ -8,3 +8,24 @@
os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')),
)
INSTALLED_APPS = ['l10n_render', 'django.contrib.auth', 'django.contrib.contenttypes']
+
+TEMPLATES = [
+ {
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'DIRS': [
+ os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')),
+ ],
+ 'APP_DIRS': True,
+ 'OPTIONS': {
+ 'context_processors': [
+ 'django.contrib.auth.context_processors.auth',
+ 'django.template.context_processors.debug',
+ 'django.template.context_processors.i18n',
+ 'django.template.context_processors.media',
+ 'django.template.context_processors.static',
+ 'django.template.context_processors.tz',
+ 'django.contrib.messages.context_processors.messages',
+ ],
+ },
+ },
+]
View
21 djangobench/benchmarks/template_compilation/settings.py
@@ -1 +1,20 @@
-from djangobench.base_settings import *
+from djangobench.base_settings import *
+
+TEMPLATES = [
+ {
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'DIRS': [],
+ 'APP_DIRS': True,
+ 'OPTIONS': {
+ 'context_processors': [
+ 'django.contrib.auth.context_processors.auth',
+ 'django.template.context_processors.debug',
+ 'django.template.context_processors.i18n',
+ 'django.template.context_processors.media',
+ 'django.template.context_processors.static',
+ 'django.template.context_processors.tz',
+ 'django.contrib.messages.context_processors.messages',
+ ],
+ },
+ },
+]
View
22 djangobench/benchmarks/template_render/settings.py
@@ -7,3 +7,25 @@
os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')),
)
ROOT_URLCONF = 'template_render.urls'
+
+
+TEMPLATES = [
+ {
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'DIRS': [
+ os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')),
+ ],
+ 'APP_DIRS': True,
+ 'OPTIONS': {
+ 'context_processors': [
+ 'django.contrib.auth.context_processors.auth',
+ 'django.template.context_processors.debug',
+ 'django.template.context_processors.i18n',
+ 'django.template.context_processors.media',
+ 'django.template.context_processors.static',
+ 'django.template.context_processors.tz',
+ 'django.contrib.messages.context_processors.messages',
+ ],
+ },
+ },
+]
View
16 djangobench/benchmarks/template_render/urls.py
@@ -1,11 +1,13 @@
try:
- from django.conf.urls import patterns, url
+ from django.conf.urls import url
except ImportError:
- from django.conf.urls.defaults import patterns, url
+ from django.conf.urls.defaults import url
+from .views import join, login, logout
-urlpatterns = patterns('template_render.views',
- url(r'/join/?$', 'join', name='join'),
- url(r'/login/?$', 'login', name='login'),
- url(r'/logout/?$', 'logout', name='logout'),
-)
+
+urlpatterns = [
+ url(r'/join/?$', join, name='join'),
+ url(r'/login/?$', login, name='login'),
+ url(r'/logout/?$', logout, name='logout'),
+]
View
19 djangobench/benchmarks/template_render_simple/settings.py
@@ -1 +1,20 @@
from djangobench.base_settings import *
+
+TEMPLATES = [
+ {
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'DIRS': [],
+ 'APP_DIRS': True,
+ 'OPTIONS': {
+ 'context_processors': [
+ 'django.contrib.auth.context_processors.auth',
+ 'django.template.context_processors.debug',
+ 'django.template.context_processors.i18n',
+ 'django.template.context_processors.media',
+ 'django.template.context_processors.static',
+ 'django.template.context_processors.tz',
+ 'django.contrib.messages.context_processors.messages',
+ ],
+ },
+ },
+]
View
16 djangobench/benchmarks/url_resolve_flat/urls.py
@@ -1,7 +1,7 @@
try:
- from django.conf.urls import patterns, include, url
+ from django.conf.urls import include, url
except ImportError:
- from django.conf.urls.defaults import patterns, include, url
+ from django.conf.urls.defaults import include, url
def ok_view(request, *a, **kw):
pass
@@ -12,17 +12,17 @@ def handler404(request):
sections = ["section%d" % i for i in range(10)]
features = ["feature%d" % i for i in range(20)]
-urlpatterns = patterns('', *[
+urlpatterns = [
url("^%s/%s$" % (s, f), ok_view) for s in sections for f in features
-])
+]
-urlpatterns += patterns('', *[
+urlpatterns += [
url("^(?P<locale>en|ru)/%s$" % f, ok_view)
for f in features
-])
+]
-urlpatterns += patterns('', *[
+urlpatterns += [
url("^(?P<user>\w+)/(?P<repo>\w+)/%s$" % f, ok_view) for f in features
-])
+]
# Total: 240 patterns
View
16 djangobench/benchmarks/url_resolve_flat_i18n_off/urls.py
@@ -1,7 +1,7 @@
try:
- from django.conf.urls import patterns, include, url
+ from django.conf.urls import include, url
except ImportError:
- from django.conf.urls.defaults import patterns, include, url
+ from django.conf.urls.defaults import include, url
def ok_view(request, *a, **kw):
pass
@@ -12,17 +12,17 @@ def handler404(request):
sections = ["section%d" % i for i in range(10)]
features = ["feature%d" % i for i in range(20)]
-urlpatterns = patterns('', *[
+urlpatterns = [
url("^%s/%s$" % (s, f), ok_view) for s in sections for f in features
-])
+]
-urlpatterns += patterns('', *[
+urlpatterns += [
url("^(?P<locale>en|ru)/%s$" % f, ok_view)
for f in features
-])
+]
-urlpatterns += patterns('', *[
+urlpatterns += [
url("^(?P<user>\w+)/(?P<repo>\w+)/%s$" % f, ok_view) for f in features
-])
+]
# Total: 240 patterns
View
12 djangobench/benchmarks/url_resolve_nested/urls.py
@@ -1,9 +1,9 @@
import string
try:
- from django.conf.urls import include, patterns, url
+ from django.conf.urls import include, url
except ImportError:
- from django.conf.urls.defaults import include, patterns, url
+ from django.conf.urls.defaults import include, url
def ok_view(request, *a, **kw):
@@ -12,7 +12,7 @@ def ok_view(request, *a, **kw):
def handler500(request):
pass
-leaf_patterns = patterns('', url(r"^leaf$", ok_view))
+leaf_patterns = [url(r"^leaf$", ok_view)]
def int2ascii(x, mod, alphabet=string.digits + string.ascii_letters):
alphabet = alphabet[:mod]
@@ -26,10 +26,8 @@ def pattern_tree(parent, height, level):
if height == 0:
return leaf_patterns
ids = [parent + int2ascii(i, level) for i in range(level)]
- return patterns('',
- *(url("^%s/" % id_, include(pattern_tree(id_, height-1, level)))
- for id_ in ids)
- )
+ return [url("^%s/" % id_, include(pattern_tree(id_, height-1, level)))
+ for id_ in ids]
urlpatterns = pattern_tree("", 8, 2)
# Total: 2**8 = 256 leafs, 511 nodes

0 comments on commit d6bb6c6

Please sign in to comment.