ok
This commit is contained in:
37
main.py
37
main.py
@@ -167,20 +167,25 @@ def readAndWriteMonetDB():
|
||||
def randomWriteMonetDB(n):
|
||||
global rapport
|
||||
time = 0
|
||||
min = 0
|
||||
max = 0
|
||||
for i in range(n):
|
||||
requete = """INSERT INTO flights ("YEAR","MONTH","DAY","DAY_OF_WEEK","AIRLINE","FLIGHT_NUMBER","TAIL_NUMBER","ORIGIN_AIRPORT","DESTINATION_AIRPORT","SCHEDULED_DEPARTURE","DEPARTURE_TIME") VALUES ("""
|
||||
requete += str(random.randint(2015,2016)) + "," + str(random.randint(1,12)) + "," + str(random.randint(1,31)) + "," + str(random.randint(1,7)) + ",'AA'," + str(random.randint(1,1000)) + ",'N1','JFK','LAX'," + str(random.randint(0,2400)) + "," + str(random.randint(0,2400)) + ");"
|
||||
time = execMonetDB(requete)[0]
|
||||
time += execMonetDB(requete)[0]
|
||||
|
||||
if(time<min or min == 0) :
|
||||
min = time
|
||||
if(time>max) :
|
||||
max = time
|
||||
time = time/n
|
||||
result = "[MonetDB] requete (moyenne de " + str(n) +") : INSERT INTO flights random value \n\ttime = " + str(time) + " s"
|
||||
result = "[MonetDB] requete (moyenne de " + str(n) +") : INSERT INTO flights random value \n\ttime = " + str(time) + " s" + "\n\tmin time = " + str(min) + "\n\tmax time = " + str(max)
|
||||
rapport = rapport + "\n" + result
|
||||
print(result)
|
||||
|
||||
|
||||
def writeMonetDB():
|
||||
randomWriteMonetDB(100)
|
||||
randomWriteMonetDB(100)
|
||||
randomWriteMonetDB(100)
|
||||
randomWriteMonetDB(1000)
|
||||
|
||||
|
||||
|
||||
@@ -282,19 +287,23 @@ def readAndWritePostgreSQL():
|
||||
def randomWritePostgreSQL(n):
|
||||
global rapport
|
||||
time = 0
|
||||
min = 0
|
||||
max = 0
|
||||
for i in range(n):
|
||||
requete = """INSERT INTO flights ("YEAR","MONTH","DAY","DAY_OF_WEEK","AIRLINE","FLIGHT_NUMBER","TAIL_NUMBER","ORIGIN_AIRPORT","DESTINATION_AIRPORT","SCHEDULED_DEPARTURE","DEPARTURE_TIME") VALUES ("""
|
||||
requete += str(random.randint(2015,2016)) + "," + str(random.randint(1,12)) + "," + str(random.randint(1,31)) + "," + str(random.randint(1,7)) + ",'AA'," + str(random.randint(1,1000)) + ",'N1','JFK','LAX'," + str(random.randint(0,2400)) + "," + str(random.randint(0,2400)) + ");"
|
||||
time = execPostgreSQL(requete)[0]
|
||||
time += execPostgreSQL(requete)[0]
|
||||
if(time<min or min == 0) :
|
||||
min = time
|
||||
if(time>max) :
|
||||
max = time
|
||||
time = time/n
|
||||
result = "[PostgreSQL] requete (moyenne de " + str(n) +") : INSERT INTO flights random value \n\ttime = " + str(time) + " s"
|
||||
result = "[PostgreSQL] requete (moyenne de " + str(n) +") : INSERT INTO flights random value \n\ttime = " + str(time) + " s" + "\n\tmin time = " + str(min) + "\n\tmax time = " + str(max)
|
||||
rapport = rapport + "\n" + result
|
||||
print(result)
|
||||
|
||||
def writePostgreSQL():
|
||||
randomWritePostgreSQL(100)
|
||||
randomWritePostgreSQL(100)
|
||||
randomWritePostgreSQL(100)
|
||||
randomWritePostgreSQL(1000)
|
||||
|
||||
|
||||
|
||||
@@ -346,8 +355,8 @@ if __name__ == '__main__':
|
||||
print(rapport)
|
||||
print("/////////////////////////////////////////////////////////////")
|
||||
|
||||
#date = datetime.now()
|
||||
#nom_fichier = "result" + date.strftime("_%d_%m_%y_%H_%M_%S") + ".txt" #un nom de fichier unique pour ne pas écraser les anciens résultats
|
||||
#with open(nom_fichier, 'w') as fichier:
|
||||
# fichier.write(rapport)
|
||||
date = datetime.now()
|
||||
nom_fichier = "result" + date.strftime("_%d_%m_%y_%H_%M_%S") + ".txt" #un nom de fichier unique pour ne pas écraser les anciens résultats
|
||||
with open(nom_fichier, 'w') as fichier:
|
||||
fichier.write(rapport)
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user