Created
June 13, 2016 02:56
-
-
Save tanner0101/6d842b9be4b00de78074d2d1dc9426a2 to your computer and use it in GitHub Desktop.
Django Benchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf.urls import url | |
from django.http import HttpResponse | |
from django.http import JsonResponse | |
from django.db import connection | |
def plaintext(request): | |
return HttpResponse('Hello, world') | |
def json(request): | |
return JsonResponse({ | |
"array": [1, 2, 3], | |
"dict": {"one": 1, "two": 2, "three": 3}, | |
"int": 42, | |
"string": "test", | |
"double": 3.14, | |
"null": None | |
}) | |
def sqlite(request): | |
cursor = connection.cursor() | |
cursor.execute("SELECT * FROM users ORDER BY random() LIMIT 1") | |
row = cursor.fetchone() | |
return JsonResponse(row, safe=False) | |
urlpatterns = [ | |
url(r'^plaintext', plaintext), | |
url(r'^json', json), | |
url(r'^sqlite-fetch', sqlite) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment