locustfile.py
1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
import time
import random
from locust import HttpUser, task, between, constant, tag
base_dir = '/home/lk/MyProject/BMW_F3OCR/数据集/文件分类/营业执照'
file_path_list = [os.path.join(base_dir, file_name) for file_name in os.listdir(base_dir)]
class QuickstartUser(HttpUser):
# wait_time = between(1, 5)
@tag('sync')
@task
def sync_test(self):
self.client.get("/sync")
@tag('async')
@task
def async_test(self):
self.client.get("/async")
@tag('sync_classification')
@task
def sync_classification(self):
img_path = random.choice(file_path_list)
files=[('image', ('', open(img_path,'rb'), ''))]
self.client.post("/sync_classification", files=files)
@tag('async_classification')
@task
def async_classification(self):
img_path = random.choice(file_path_list)
files=[('image', ('', open(img_path,'rb'), ''))]
self.client.post("/async_classification", files=files)