我希望 Locust 使用我电脑上的所有内核。
\n我有很多 Locust 类,我想使用 Locust 作为库。
\n我的代码示例:
\nimport gevent\nfrom locust.env import Environment\nfrom locust.stats import stats_printer\nfrom locust.log import setup_logging\nimport time\n\n\n\nfrom locust import HttpUser, TaskSet, task, between\n\n\ndef index(l):\n l.client.get("/")\n\ndef stats(l):\n l.client.get("/stats/requests")\n\nclass UserTasks(TaskSet):\n # one can specify tasks like this\n tasks = [index, stats]\n\n # but it might be convenient to use the @task decorator\n @task\n def page404(self):\n self.client.get("/does_not_exist")\n\nclass WebsiteUser(HttpUser):\n """\n User class that does requests to the locust web server running on localhost\n """\n host = "http://127.0.0.1:8089"\n …Run Code Online (Sandbox Code Playgroud)