testLiaSoap.py 1.42 KB
from suds.client import Client
import time
import threading

 ### TODO : Tester en parallele x4  un million de fois pour voir ###
url = 'http://194.57.216.156:8181/?wsdl'
client = Client(url)
filename = "data.txt"
file = open(filename, "r")
nb_times=4
# Exp 1
debut =time.time()
contents = file.read().decode("utf8").encode("ascii", errors='ignore').rstrip()
client.service.get_phon(contents)
duree= time.time()- debut
print (" Exper 1 : " + str(duree))
# Exp 2
debut =time.time()
file.seek(0)
lines = file.readlines()
for line in lines:
    line = line.decode("utf8").encode("ascii", errors='ignore').rstrip() 
    if line is not None:
        try:
            client.service.get_phon(line)
        except:
            continue
duree= time.time()- debut
print (" Exper 2 line by line 1 corpus  : " + str(duree))
##Exp 3
debut = time.time()
file.seek(0)
contents = file.read().decode("utf8").encode("ascii", errors='ignore').rstrip()
tabs=[]
i=0
while i <= nb_times :
    tabs.append(contents)
    i+=1
client.service.get_phon("".join(tabs))
duree= time.time()- debut
print ("Exper 3  2pow4  time the content in once shot " + str(duree))
# EXP 4 
#debut = time.time()
#contents = file.read().decode("utf8").encode("ascii", errors='ignore').rstrip()
#def envoie(datas):
#    client.service.get_phon(datas)
#i =0 
#threadTab= []
#while i <= nb_times:
#    threadTab.append(threading.Thread(None, envoie, None,contents,None))
#duree = time.time() - debut