diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..04be7f4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,92 @@ + +## Python +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# IPython Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# dotenv +.env + +# virtualenv +.venv/ +venv/ +ENV/ + +# Spyder project settings +.spyderproject + +# Rope project settings +.ropeproject diff --git a/README.md b/README.md new file mode 100644 index 0000000..2f81201 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ + +Usage +===== + +``` +$ pip install -r requirements +$ locust -f locustfile.py --host=https://lowiki.tw +# check +``` diff --git a/locustfile.py b/locustfile.py new file mode 100644 index 0000000..1bb9b3f --- /dev/null +++ b/locustfile.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# encoding=utf-8 + +from locust import HttpLocust, TaskSet, task + +class WebsiteTasks(TaskSet): + # def on_start(self): + # self.client.post("/Users/login/?next=//lowiki.tw/", { + # "username": "anonymous", + # "password": "foobarbaz" + # }) + + @task + def region(self): + self.client.get("/tw1000201-027/") + + @task + def edit_frontpage(self): + self.client.get("/tw1000201-027/Front_Page/_edit") + + @task + def map(self): + self.client.get("/tw1000201-027/map/") + + @task + def edit_page(self): + self.client.get(u"/tw1000201-027/梅洲里鎮平宮/_edit") + + @task + def tags(self): + self.client.get(u"/tw1000201-027/tags/避難收容處所") + +class WebsiteUser(HttpLocust): + host = "https://lowiki.tw" + task_set = WebsiteTasks + min_wait = 5000 + max_wait = 15000 + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..84808de --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +locustio==0.7.5 +pyzmq==15.4.0