Use local webserver for speed testing (#108)

* tests: Add script to set up local server

* tests: Remove old results from speed.csv since test methodology changes

* tests: Change speed_regression so it downloads locally hosted webserver

* local_server_setup: Remove need of sudo since suckit understands ports

* speed_regression: Start local web server in script

Co-authored-by: Esteban Blanc <estblcsk@gmail.com>
This commit is contained in:
CohenArthur 2021-01-06 11:10:38 +01:00 committed by GitHub
parent 56c3970edd
commit 299247a107
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 19 deletions

3
.gitignore vendored
View file

@ -6,3 +6,6 @@
tags
.idea/
# Ignore local web server folder
tests/local_server

33
tests/local_server_setup.sh Executable file
View file

@ -0,0 +1,33 @@
#!/bin/sh
set -e
# Create the local's server directory if necessary
if [[ ! -d local_server ]]; then
mkdir local_server
fi
cd local_server
# Clone repository if necessary
if [[ ! -d linux ]]; then
# Clone a big repository
git clone https://github.com/torvalds/linux
cd linux
# Checkout the 5.9 release
git checkout v5.9
# No need for the .git directory. It creates a ton of files that take too long
# to scrape
rm -rf .git
# Get back to local_server
cd ..
fi
printf "\nWEBSERVER UP\n"
# Start up the local python server
python3 -m http.server

View file

@ -1,16 +1 @@
1, 1, 1
92.01026630401611, 45.85903334617615, 24.938209056854248
92.68794660568237, 45.51665663719177, 36.877896785736084
94.26381759643554, 48.01623530387879, 39.034280157089235
94.51657667160035, 47.43879041671753, 25.296046495437622
94.91624474525452, 47.318924236297605, 38.720614719390866
94.61654992103577, 57.59067335128784, 24.995196104049683
95.28456358909607, 46.86330976486206, 24.708560609817503
77.68792352676391, 39.08626494407654, 19.765260219573975
67.09948434829712, 34.11661868095398, 17.574066400527954
68.2605634689331, 33.728125953674315, 17.433270835876463
70.19220662117004, 41.964057207107544, 17.660782480239867
68.06500535011291, 34.10616636276245, 28.643333148956298
67.92092838287354, 33.87600998878479, 17.644397974014282
67.94186737537385, 33.967066860198976, 17.586638736724854
68.20248901844025, 37.70992383956909, 22.916122150421142

1 1 1 1
92.01026630401611 45.85903334617615 24.938209056854248
92.68794660568237 45.51665663719177 36.877896785736084
94.26381759643554 48.01623530387879 39.034280157089235
94.51657667160035 47.43879041671753 25.296046495437622
94.91624474525452 47.318924236297605 38.720614719390866
94.61654992103577 57.59067335128784 24.995196104049683
95.28456358909607 46.86330976486206 24.708560609817503
77.68792352676391 39.08626494407654 19.765260219573975
67.09948434829712 34.11661868095398 17.574066400527954
68.2605634689331 33.728125953674315 17.433270835876463
70.19220662117004 41.964057207107544 17.660782480239867
68.06500535011291 34.10616636276245 28.643333148956298
67.92092838287354 33.87600998878479 17.644397974014282
67.94186737537385 33.967066860198976 17.586638736724854
68.20248901844025 37.70992383956909 22.916122150421142

View file

@ -1,7 +1,7 @@
#!/usr/bin/python3
# Number of tests for each bench-set
TEST_RETRIES = 10
TEST_RETRIES = 20
# File to store the results
FILENAME = "speed.csv"
@ -9,8 +9,8 @@ FILENAME = "speed.csv"
# Path to the suckit binary
SUCKIT = "suckit"
# URL to download
URL = "http://books.toscrape.com"
# URL to download: localhost
URL = "http://0.0.0.0:8000"
# Path to store the downloaded data
PATH = "/tmp/suckit_speed"
@ -23,6 +23,18 @@ import subprocess
import time
from termcolor import colored
def start_webserver():
print("Launching webserver")
webserver_pid = subprocess.Popen(["./local_server_setup.sh"], stdout = subprocess.PIPE)
while webserver_pid.stdout.readline() != b"WEBSERVER UP\n":
print("Waiting on webserver...", end = "\r")
print("Webserver launched")
return webserver_pid
def parse_args():
global FILENAME
global SUCKIT
@ -120,4 +132,14 @@ def main():
shutil.rmtree(PATH)
if __name__ == "__main__":
webserver_pid = None
try:
webserver_pid = start_webserver()
main()
# Terminate the webserver
webserver_pid.kill()
except: # Kill the webserver if an exception occurs
webserver_pid.kill()