django / django-asv

Benchmarks for Django using asv

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding request response benchmarks

deepakdinesh1123 opened this issue · comments

In the TODO file in djangobench, it was mentioned that a running test server might be required for the benchmark so I tried to do this by using a sample django project and the subprocess module

import subprocess

class Benchmark:
    def setup(self):
          self.process = subprocess.Popen(["python", "manage.py", "runserver"])
    
    def teardown(self):
          self.process.kill()
    
    def time_response(self):
         # benchmark...

But when I tried to access the manage.py file in the django project I got an error
LookupError: No installed app with label 'admin' whenever I tried to run the benchmarks.

After this I tried to set it up with docker but could not find a way to provide the commit hash so that the particular commit can be installed. It can be implemented in the workflow by using the python docker SDK to build the images that use particular commit hashes of django or use a shell script to pass commits to dockerfile, and use a script to start them and further benchmark them using ASV. Shall I go with this method?

Are there any other ways in which this can be done? Should I also try options other than ASV?

WSGIHandler is callable directly... which is what the WSGI server, such as gunicorn does, so we should be able to provide an environment dictionary, and a start_reponse callable and just pass those, without needing to run the full web server...

Look in django/django tests/handlers/tests.py for examples doing just this. https://github.com/django/django/blob/main/tests/handlers/tests.py

See also the WSGI spec: https://peps.python.org/pep-3333/#specification-details

We should then be able to do similar with ASGI, and with testing different changes (to signal dispatch for example).
Good stuff! 👍