from square_align_list_perf_as_package import UserTest
print(UserTest)
import gevent
from locust import HttpUser, task, between
from locust.env import Environment
from locust.stats import stats_printer, stats_history
from locust.log import setup_logging
setup_logging("DEBUG", None)
def master():
master_env = Environment(user_classes=[UserTest])
master_env.create_master_runner()
# 启动一个greenlet,定期输出当前统计信息
gevent.spawn(stats_printer(master_env.stats))
master_env.runner.start(100, spawn_rate=10)
gevent.spawn_later(10, lambda: master_env.runner.quit()))
master_env.runner.greenlet.join()
if __name__ == "__main__":
master()
from square_align_list_perf_as_package import UserTest
print(UserTest)
import gevent
from locust import HttpUser, task, between
from locust.env import Environment
from locust.stats import stats_printer, stats_history
from locust.log import setup_logging
setup_logging("DEBUG", None)
def worker():
env = Environment(user_classes=[UserTest])
env.create_worker_runner(master_host="0.0.0.0", master_port=5557)
env.runner.start_worker(user_classes_count={"UserTest": 50})
env.runner.heartbeat()
env.runner.worker()
env.runner.stats_reporter()
env.runner.greenlet.join()
if __name__ == "__main__":
print("main")
worker()