-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHRAPerformanceTester.py
More file actions
47 lines (42 loc) · 2.1 KB
/
HRAPerformanceTester.py
File metadata and controls
47 lines (42 loc) · 2.1 KB
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
#########################################################################################################
# Program Name : HRAPerformanceTester.py #
# Program Description: #
# This program processes an address dataset against HRA and determines response time #
# #
# Comment Date Author #
# ================================ ========== ================ #
# Initial Version 12/07/2018 Engramar Bollas #
#########################################################################################################
import httplib2 as http
import json
import sys
import time
try:
from urlparse import urlparse
except ImportError:
from urllib.parse import urlparse
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json; charset=UTF-8'
}
#########################################################################################################
# Change this URL to either au or nz #
#########################################################################################################
uri = 'http://localhost:8080/HRAWeb/hra/rest/au/address/similar-addresses'
target = urlparse(uri)
method = 'POST'
infile = open("HRAPeformanceInput.txt", 'r')
outfile = open("HRAPerformanceTesterOutput.txt",'w')
for address in infile:
body = '{"option": {"locale": "AU","baseSource": "GNAF"},"payload":{"fullAddress":%s}}' % address
h = http.Http()
start_time = time.time()
response, content = h.request(
target.geturl(),
method,
body,
headers)
end_time = time.time()
elapsed_time = end_time - start_time
outfile.write(str(elapsed_time)+'\n')
#elapsed_time_ms = int(round(elapsed_time * 1000)