-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_extrasensory_prediction.py
61 lines (56 loc) · 1.27 KB
/
test_extrasensory_prediction.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
import requests
import json
import time
import numpy as np
import sys
port = 8080
request_url = 'edusense-compute-5.andrew.cmu.edu'
print("Testing service on port:", port)
st_times = int(time.time())
timestamps = np.arange(st_times, st_times + (80 * 60), 60)
activity_list = [
"lying",
"sitting",
"walking",
"running",
"cycling",
"sleeping",
"office_work",
"meeting",
"driving",
"exercising",
"cooking",
"shopping",
"drinking",
"shower",
"cleaning",
"laundry",
"clean_dishes",
"watching_tv",
"surfing_internet",
"singing",
"talking",
"eating",
"toilet",
"grooming",
"dressing_up",
"stairs",
"standing",
"meeting_coworkers",
"meeting_friends"
]
activities = []
for i in range(40):
num_pars = np.random.randint(low=1, high=2)
activities_arr = np.random.choice(activity_list, num_pars)
activities.append(','.join(activities_arr))
st = time.time()
responses = []
for i in range(40):
response = requests.get(
f"http://{request_url}:{port}/extrasensory?timestamp={timestamps[i]}&activities={activities[i]}")
print(response.text)
responses.append(response.text)
total_time = time.time() - st
response_dict = json.loads(response.text)
print(total_time)