Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding request response benchmarks #61

Open
deepakdinesh1123 opened this issue Aug 4, 2022 · 1 comment
Open

Adding request response benchmarks #61

deepakdinesh1123 opened this issue Aug 4, 2022 · 1 comment

Comments

@deepakdinesh1123
Copy link
Contributor

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?

@carltongibson
Copy link
Member

carltongibson commented Aug 9, 2022

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! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants