-
Notifications
You must be signed in to change notification settings - Fork 5
/
temp
85 lines (69 loc) · 1.92 KB
/
temp
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# import contextlib
# import io
# import os
# import random
# import time
# import uuid
# import urllib
# import requests
# from locust import HttpLocust, TaskSet, task, between
import requests
import json
import numpy
TARGET_IMAGE_FILES = [
# XXX: from https://randomuser.me/photos
*[f"https://randomuser.me/api/portraits/men/{idx}.jpg" for idx in range(200)],
*[f"https://randomuser.me/api/portraits/women/{idx}.jpg" for idx in range(200)],
# XXX: from https://tinyfac.es/
]
# FETCHED_IMAGE_FILES = {}
URL = 'http://localhost:80/eval/image'
headers = {'Content-Type': 'application/json; charset=utf-8'}
data = []
a = 1
for url in TARGET_IMAGE_FILES:
response = requests.post(URL, headers=headers, data=json.dumps({
"url": url
}))
print(a)
a = a + 1
data.append(float(response.json()['score']))
print(data)
print(len(data))
print('평균')
print(numpy.mean(data))
print('분산')
print(numpy.var(data))
print('표준편차')
print(numpy.std(data))
# class UserTaskSet(TaskSet):
# @task
# def send(self):
# req_id = str(uuid.uuid4()) # XXX: Just for tracing
# picked_image = random.choice(TARGET_IMAGE_FILES)
# taskname = 'eval/image'
# started = time.time()
# response = self.client.get(f"{taskname}?url={picked_image}")
# ended = time.time()
# duration = ended - started
# print(
# (
# "out",
# req_id,
# taskname,
# duration,
# response.status_code,
# len(response.content),
# )
# )
# TARGET_RPS = 10
# class User(HttpLocust):
# task_set = UserTaskSet
# def wait_time(self):
# target_wait = between(0, 1 / TARGET_RPS)(self)
# print(("wait", target_wait))
# return target_wait
# if __name__ == "__main__":
# ts = UserTaskSet()
# ts.client = requests
# ts.send()