print("\nThis test will run some function on two database to compare their robustness, The robustness of a database depends on its length, this is why the minimum length of the two files will be the maximum reference for both files\n")
before=time.time()
firstFile=Robustness(sys.argv[1])
after=time.time()
print("First file loaded in %d seconds."%(after-before))
before=time.time()
secondFile=Robustness(sys.argv[2])
after=time.time()
print("Second file loaded in %d seconds.\n"%(after-before),)
print("d =",firstFile.k," first file got a median of :",l1[int(len(l1)/2)],"while the second one got a median of: ",l2[int(len(l2)/2)]," (100 iterations)")
res.append(l1[int(len(l1)/2)]>l2[int(len(l2)/2)])
firstFile.k,secondFile.k=1000000,1000000
l1,l2=[],[]
foriinrange(100):
l1.append(firstFile.cost_rate())
l2.append(secondFile.cost_rate())
l1=sorted(l1)
l2=sorted(l2)
print("d =",firstFile.k," first file got a median of :",l1[int(len(l1)/2)],"while the second one got a median of: ",l2[int(len(l2)/2)]," (100 iterations)")
res.append(l1[int(len(l1)/2)]>l2[int(len(l2)/2)])
firstFile.k,secondFile.k=mini_D,mini_D
l1,l2=[],[]
foriinrange(10):
l1.append(firstFile.cost_rate())
l2.append(secondFile.cost_rate())
l1=sorted(l1)
l2=sorted(l2)
print("d =",firstFile.k," first file got a median of :",l1[int(len(l1)/2)],"while the second one got a median of: ",l2[int(len(l2)/2)]," (10 iterations)")
print("d =",firstFile.k," first file got a median of :",l1[int(len(l1)/2)],"while the second one got a median of: ",l2[int(len(l2)/2)]," (100 iterations)")
res.append(l1[int(len(l1)/2)]>l2[int(len(l2)/2)])
firstFile.k,secondFile.k=100000,100000
l1,l2=[],[]
foriinrange(10):
l1.append(firstFile.min_cost())
l2.append(secondFile.min_cost())
l1=sorted(l1)
l2=sorted(l2)
print("d =",firstFile.k," first file got a median of :",l1[int(len(l1)/2)],"while the second one got a median of: ",l2[int(len(l2)/2)]," (10 iterations)")
res.append(l1[int(len(l1)/2)]>l2[int(len(l2)/2)])
firstFile.k,secondFile.k=1000000,1000000
l1,l2=[],[]
foriinrange(10):
l1.append(firstFile.min_cost())
l2.append(secondFile.min_cost())
l1=sorted(l1)
l2=sorted(l2)
print("d =",firstFile.k," first file got a median of :",l1[int(len(l1)/2)],"while the second one got a median of: ",l2[int(len(l2)/2)]," (10 iterations)")
print("d =",k," and m = 10, first file got a median of :",l1[int(len(l1)/2)],"while the second one got a median of: ",l2[int(len(l2)/2)]," (10 iterations)")
res.append(l1[int(len(l1)/2)]>l2[int(len(l2)/2)])
l1,l2=[],[]
foriinrange(10):
k=10000
perm1=R.closest_word_among(m=100)
perm2=R.closest_word_among(m=100)
foriinrange(k):
cost1=next(perm1)[1]
cost2=next(perm2)[1]
l1.append(cost1)
l2.append(cost2)
l1=sorted(l1)
l2=sorted(l2)
print("d =",k," and m = 100, first file got a median of :",l1[int(len(l1)/2)],"while the second one got a median of: ",l2[int(len(l2)/2)]," (10 iterations)")
res.append(l1[int(len(l1)/2)]>l2[int(len(l2)/2)])
l1,l2=[],[]
foriinrange(10):
k=100000
perm1=R.closest_word_among(m=10)
perm2=R.closest_word_among(m=10)
foriinrange(k):
cost1=next(perm1)[1]
cost2=next(perm2)[1]
l1.append(cost1)
l2.append(cost2)
l1=sorted(l1)
l2=sorted(l2)
print("d =",k," and m = 10, first file got a median of :",l1[int(len(l1)/2)],"while the second one got a median of: ",l2[int(len(l2)/2)]," (10 iterations)")
res.append(l1[int(len(l1)/2)]>l2[int(len(l2)/2)])
l1,l2=[],[]
foriinrange(10):
k=100000
perm1=R.closest_word_among(m=100)
perm2=R.closest_word_among(m=100)
foriinrange(k):
cost1=next(perm1)[1]
cost2=next(perm2)[1]
l1.append(cost1)
l2.append(cost2)
l1=sorted(l1)
l2=sorted(l2)
print("d =",k," and m = 100, first file got a median of :",l1[int(len(l1)/2)],"while the second one got a median of: ",l2[int(len(l2)/2)]," (10 iterations)")