GithubHelp home page GithubHelp logo

maddyguthridge / best-test-request Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 223 KB

Figuring out the most efficient way to send requests to test web servers

License: MIT License

Python 65.48% JavaScript 34.52%

best-test-request's Introduction

Best Test Request

Figuring out the most efficient method to send requests to test web servers.

Context

I've been experimenting with various ways to try and speed up COMP1531's test runners, and also check how the performance of various other request-related things relate.

Findings

Here's a link to the results.

  • Using sync-request is about 5x slower than using the fetch API.
  • Python is about twice as slow as JS when sending real requests.
  • When injecting fake requests using Flask's testing library (instead of sending real requests), performance improves by 5x.
  • If we can find a library to inject fake requests into Express, we may be able to get a similar performance improvement, meaning the improvement would be 25x compared to using sync-request.

Usage

Here's how you can run the benchmarks on your own machine.

Note: I'm using Poetry as the dependency management tool for Python. You'll need to install it.

  1. Install Python dependencies with poetry install
  2. Install JS dependencies with npm install
  3. Run the test script with poetry run python runner.py

You can use --progress to get a live counter (so you know it hasn't broken)

You can also customise the particular variations that are run by editing runner.py.

List of variations

Flask

Run server using poetry run python -m flask_app

All combinations of:

Request strategy

  • requests library to send requests
  • flask.testing library to send fake requests

Request method

  • GET with query string
  • POST with JSON

JSON encoder

  • Flask's jsonify function
  • Standard json library

Express

Run server using npm start

All combinations of:

Request strategy

  • sync-request to send requests
  • Node's built-in fetch to send requests

Request method

  • GET with query string
  • POST with JSON

best-test-request's People

Contributors

maddyguthridge avatar nktnet1 avatar

Watchers

 avatar

Forkers

nktnet1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.