-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimer.py
67 lines (53 loc) · 2.86 KB
/
timer.py
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
import requests
import datetime
import statistics as stat
SERVICE_1_ENDPOINT = "http://localhost:5000"
SERVICE_2_ENDPOINT = "http://localhost:8080/api"
SERVICE_3_ENDPOINT = "https://api.eu-gb.text-to-speech.watson.cloud.ibm.com/instances/a02d1a2d-2e39-42af-871e-3e8007f2e5e3"
NUM_TRIALS = 50
API_KEY = "zYAH4XzJ_X6U-RetmZw-Y0-1L2a8uG_qrE5MTKzM7-SM"
time_tracker = {
"SERVICE_1_ENDPOINT": [],
"SERVICE_2_ENDPOINT": [],
"SERVICE_3_ENDPOINT": []
}
for i in range(NUM_TRIALS):
time_start = datetime.datetime.now()
recipes = requests.get(SERVICE_2_ENDPOINT + f'/all_dishes')
time_end = datetime.datetime.now()
time_tracker["SERVICE_2_ENDPOINT"].append(time_end - time_start)
for i in range(NUM_TRIALS):
time_start = datetime.datetime.now()
recipes = requests.get(SERVICE_1_ENDPOINT + f'/all_dishes')
time_end = datetime.datetime.now()
time_tracker["SERVICE_1_ENDPOINT"].append(time_end - time_start)
for i in range(NUM_TRIALS):
time_start = datetime.datetime.now()
recipes = requests.get(SERVICE_3_ENDPOINT + "/v1/synthesize",
auth = ('apikey', API_KEY), params = {
"accept": "audio/mp3",
"text": "Hello World",
"voice": "en-US_AllisonV3Voice"
})
time_end = datetime.datetime.now()
time_tracker["SERVICE_3_ENDPOINT"].append(time_end - time_start)
print("####################################################################")
print("# SERVICE_1_ENDPOINT #")
print("####################################################################")
print("Mean(s): ", stat.mean([x.total_seconds() for x in time_tracker["SERVICE_1_ENDPOINT"]]))
print("Standard Deviation:", stat.stdev([x.total_seconds() for x in time_tracker["SERVICE_1_ENDPOINT"]]))
print("\n\n")
print("####################################################################")
print("# SERVICE_2_ENDPOINT #")
print("####################################################################")
print("Mean(s): ", stat.mean([x.total_seconds() for x in time_tracker["SERVICE_2_ENDPOINT"]]))
print("Standard Deviation:", stat.stdev([x.total_seconds() for x in time_tracker["SERVICE_2_ENDPOINT"]]))
print("\n\n")
print("####################################################################")
print("# SERVICE_3_ENDPOINT #")
print("####################################################################")
print("Mean(s): ", stat.mean([x.total_seconds() for x in time_tracker["SERVICE_3_ENDPOINT"]]))
print("Standard Deviation:", stat.stdev([x.total_seconds() for x in time_tracker["SERVICE_3_ENDPOINT"]]))
print("\n\n")
# print("SERVICE_2_ENDPOINT:", stat.mean([x.total_seconds() for x in time_tracker["SERVICE_2_ENDPOINT"]]))
# print("SERVICE_3_ENDPOINT:", stat.mean([x.total_seconds() for x in time_tracker["SERVICE_3_ENDPOINT"]]))