mirror of
https://github.com/UofCBaja/BajaCloud.git
synced 2025-06-15 13:14:17 -06:00
feat(testhttp): testing done python is faster for simple http get requests with only 1 endpoint
This commit is contained in:
parent
fa037fdb29
commit
403558ecb5
@ -7,8 +7,11 @@ from django.http import HttpResponse
|
||||
|
||||
# Function to generate the response
|
||||
def send_funct():
|
||||
ymlschedule = {"message": False}
|
||||
to_send = {
|
||||
"body": "Hello this is a test"
|
||||
"statusCode": 200,
|
||||
"isBase64ENcoded": "false",
|
||||
"body": json.dumps(ymlschedule)
|
||||
}
|
||||
return json.dumps(to_send)
|
||||
|
||||
|
BIN
TestResultsCodeSpace.png
Normal file
BIN
TestResultsCodeSpace.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
18
testhttp.py
Normal file
18
testhttp.py
Normal file
@ -0,0 +1,18 @@
|
||||
import json
|
||||
import requests
|
||||
import timeit
|
||||
|
||||
def BenchMarkServer():
|
||||
rawRes = requests.get("http://localhost:8080")
|
||||
res = json.loads(rawRes.text)
|
||||
#print(json.dumps(res, indent=1))
|
||||
|
||||
def BenchMarkDjango():
|
||||
rawRes = requests.get("http://localhost:8000/polls/test")
|
||||
res = json.loads(rawRes.text)
|
||||
#print(json.dumps(res, indent=1))
|
||||
|
||||
if __name__ == "__main__":
|
||||
djangoTime = timeit.timeit(stmt=BenchMarkDjango, number=10)
|
||||
pythonTime = timeit.timeit(stmt=BenchMarkServer, number=10)
|
||||
print(f"Django: {djangoTime}\nPython: {pythonTime}")
|
Loading…
x
Reference in New Issue
Block a user