#!/usr/bin/env python3
import httplib2
import json
import random

def doRequest(http,url, algSuffix, request):
   headers ={'Content-Type':'application/json', "Accept":"application/json"}
   resp, content = http.request(uri=url+"/alg"+algSuffix, method="POST", body=json.dumps(request))
   if resp['status'] == '200':
      return True, json.loads(str(content, "UTF-8"))
   else:
      return False, json.loads(str(content, "UTF-8"))


def main():
   http = httplib2.Http()
   request = {'points':[{'lt': 487786110, 'ln' : 91794440}, {'lt': 535652780, 'ln': 100013890}]}
   #random.seed(42)
   for i in range(0, 1000):
      points = []
      for i in range(0, random.randint(2,5)):
         lat = random.randint(472600000, 548960000)
         lon = random.randint( 59000000, 149900000)
         points.append({'lt': lat, 'ln' : lon})
      
      request['points'] = points
      success, content = doRequest(http, 'http://localhost:8080', 'sp', request)
      if not success:
         print('Failed: '+str(content))
      else:
         print(str(content['misc']['distance']/1000.0))

if __name__ == "__main__":
   main()

@@ -62,31 +62,126 @@
 dom%0A
-%0Adef doRequest(http,url
+import time%0A%0A%0Aclass Requester:%0A   def __init__(self, http):%0A      self.http = http%0A%0A   def doRequest(self, url, method
 , al
@@ -199,16 +199,19 @@
 quest):%0A
+   
    heade
@@ -282,16 +282,19 @@
 on%22%7D%0A   
+  
+ 
 resp, co
@@ -301,16 +301,21 @@
 ntent = 
+self.
 http.req
@@ -356,14 +356,14 @@
 hod=
-%22POST%22
+method
 , bo
@@ -389,16 +389,19 @@
 st))%0A   
+ 
+  
 if resp%5B
@@ -422,24 +422,27 @@
 200':%0A      
+  
+ 
 return True,
@@ -440,16 +440,18 @@
 urn True
+ #
 , json.l
@@ -478,16 +478,19 @@
 TF-8%22))%0A
+   
    else:
@@ -492,24 +492,27 @@
 else:%0A      
+  
+ 
 return False
@@ -511,16 +511,18 @@
 rn False
+ #
 , json.l
@@ -589,16 +589,120 @@
 .Http()%0A
+   requester = Requester(http)%0A   %0A   numRequests = 0;%0A   startTime = time.time()%0A   startRequests = 0;%0A
    reque
@@ -817,31 +817,18 @@
 %0A   
-for i in range(0, 1000)
+while True
 :%0A  
@@ -871,27 +871,9 @@
 (0, 
-random.randint(2,5)
+2
 ):%0A 
@@ -1076,28 +1076,29 @@
  success
-, content = 
+ = requester.
 doReques
@@ -1103,22 +1103,16 @@
 est(
-http, 
 'http://
 loca
@@ -1111,28 +1111,41 @@
 p://
-localhost:8080', 'sp
+192.168.178.21:8080', 'POST','nns
 ', r
@@ -1231,24 +1231,306 @@
 e:%0A         
+numRequests+=1%0A         now = time.time()%0A         if now-startTime %3E= 20.0:%0A            num = numRequests-startRequests%0A            print(str(num) + ' requests in '+str(now-startTime)+' seconds')%0A            startTime = time.time();%0A            startRequests=numRequests%0A         #
 print(str(co

Add timing to randomclient