Skip to content
Browse files

Split reverse and resolve benchmarks into two seperate ones and creat…

…ed slightly more realistic conditions.
  • Loading branch information...
1 parent 7e4abb6 commit 6fb57357ef9c5f824bb64fc4a35c326337288937 @kaip kaip committed
View
0 benchmarks/urls/__init__.py → benchmarks/url_resolve/__init__.py
File renamed without changes.
View
6 benchmarks/urls/benchmark.py → benchmarks/url_resolve/benchmark.py
@@ -1,11 +1,9 @@
-import time
-
-from django.core.urlresolvers import reverse, resolve
+from django.core.urlresolvers import resolve
from utils import run_benchmark
def benchmark():
resolve('/basic/')
- reverse('urls.views.basic')
+ resolve('/fallthroughview/')
run_benchmark(benchmark)
View
2 benchmarks/urls/settings.py → benchmarks/url_resolve/settings.py
@@ -1,4 +1,4 @@
from base_settings import *
-INSTALLED_APPS = ['urls']
+INSTALLED_APPS = ['url_resolve']
ROOT_URLCONF = 'urlconf'
View
14 benchmarks/url_resolve/urlconf.py
@@ -0,0 +1,14 @@
+from django.conf.urls.defaults import *
+
+def generate_filler_patterns(num=1):
+ """ Returns a list of url pattern inputs for garbage views """
+ for n in range(num):
+ yield (r''.join((r'^', r'x'*3*n, r'/$')), str(n))
+
+patterns_input = ['']
+patterns_input += generate_filler_patterns(10)
+patterns_input.append((r'^basic/$', 'url_resolve.views.basic'))
+patterns_input.append((r'^[a-z]*/$', 'url_resolve.views.catchall'))
+
+
+urlpatterns = patterns(*patterns_input)
View
5 benchmarks/url_resolve/views.py
@@ -0,0 +1,5 @@
+def basic():
+ pass
+
+def catchall():
+ pass
View
1 benchmarks/url_reverse/__init__.py
@@ -0,0 +1 @@
+
View
9 benchmarks/url_reverse/benchmark.py
@@ -0,0 +1,9 @@
+from django.core.urlresolvers import reverse
+
+from utils import run_benchmark
+
+def benchmark():
+ reverse('url_resolve.views.basic')
+ reverse('url_resolve.views.catchall')
+
+run_benchmark(benchmark)
View
4 benchmarks/url_reverse/settings.py
@@ -0,0 +1,4 @@
+from base_settings import *
+
+INSTALLED_APPS = ['url_reverse']
+ROOT_URLCONF = 'url_resolve.urlconf'
View
5 benchmarks/urls/urlconf.py
@@ -1,5 +0,0 @@
-from django.conf.urls.defaults import *
-
-urlpatterns = patterns('',
- (r'^basic/$', 'urls.views.basic'),
-)
View
2 benchmarks/urls/views.py
@@ -1,2 +0,0 @@
-def basic():
- pass

0 comments on commit 6fb5735

Please sign in to comment.
Something went wrong with that request. Please try again.